public function testDecodeClassName() { $className = 'Class'; $this->entityRoutingHelper->expects($this->once())->method('resolveEntityClass')->with($className)->willReturn($className); $result = $this->helper->decodeClassName($className); $this->assertEquals($result, $className); }
/** * @dataProvider supportedMethods * * @param string $method */ public function testProcessValidDataWithTargetEntityActivity($method) { $targetEntity = new TestTarget(123); $action = 'activity'; $this->request->setMethod($method); $this->form->expects($this->once())->method('setData')->with($this->identicalTo($this->entity)); $this->form->expects($this->once())->method('submit')->with($this->identicalTo($this->request)); $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->entityRoutingHelper->expects($this->once())->method('getAction')->with($this->identicalTo($this->request))->will($this->returnValue($action)); $this->entityRoutingHelper->expects($this->once())->method('getEntityClassName')->with($this->identicalTo($this->request))->will($this->returnValue(get_class($targetEntity))); $this->entityRoutingHelper->expects($this->once())->method('getEntityId')->with($this->identicalTo($this->request))->will($this->returnValue($targetEntity->getId())); $this->entityRoutingHelper->expects($this->once())->method('getEntityReference')->with(get_class($targetEntity), $targetEntity->getId())->will($this->returnValue($targetEntity)); $this->activityManager->expects($this->once())->method('addActivityTarget')->with($this->identicalTo($this->entity), $this->identicalTo($targetEntity)); $this->om->expects($this->once())->method('persist')->with($this->identicalTo($this->entity)); $this->om->expects($this->once())->method('flush'); $this->assertTrue($this->handler->process($this->entity)); }
/** * @dataProvider supportedMethods * * @param string $method */ public function testProcessValidDataWithTargetEntity($method) { $this->entity->setPhoneNumber('phone1'); $targetEntity = new TestTarget(123); $targetEntity1 = new TestTarget(456); $this->request->query->set('entityClass', get_class($targetEntity)); $this->request->query->set('entityId', $targetEntity->getId()); $this->formFactory->expects($this->once())->method('createNamed')->with('orocrm_call_form', 'orocrm_call_form', $this->entity, [])->will($this->returnValue($this->form)); $this->form->expects($this->once())->method('submit')->with($this->request); $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->phoneProvider->expects($this->never())->method('getPhoneNumber'); $this->phoneProvider->expects($this->once())->method('getPhoneNumbers')->with($this->identicalTo($targetEntity))->will($this->returnValue([['phone1', $targetEntity], ['phone2', $targetEntity], ['phone1', $targetEntity1]])); $this->entityRoutingHelper->expects($this->once())->method('getEntity')->with(get_class($targetEntity), $targetEntity->getId())->will($this->returnValue($targetEntity)); // phone1, $targetEntity $this->callActivityManager->expects($this->at(0))->method('addAssociation')->with($this->identicalTo($this->entity), $this->identicalTo($targetEntity)); // phone2, $targetEntity $this->callActivityManager->expects($this->at(1))->method('addAssociation')->with($this->identicalTo($this->entity), $this->identicalTo($targetEntity)); // phone1, $targetEntity1 $this->callActivityManager->expects($this->at(2))->method('addAssociation')->with($this->identicalTo($this->entity), $this->identicalTo($targetEntity1)); $this->manager->expects($this->once())->method('persist')->with($this->entity); $this->manager->expects($this->once())->method('flush'); $this->request->setMethod($method); $this->assertTrue($this->handler->process($this->entity)); }