Example #1
0
 public function testGetFindsRecordById()
 {
     $recordId = 1;
     /** @var ActionService|PHPUnit_Framework_MockObject_MockObject $sut */
     $sut = $this->getMock('DeskModule\\Queue\\Action\\Service', array('getRepository'));
     $mockedEntityRepository = $this->getMock('Doctrine\\ORM\\EntityRepository', array(), array(), '', false);
     $mockedEntityRepository->expects($this->once())->method('find')->with($recordId)->willReturn(Action::build()->setRecordId($recordId));
     $sut->expects($this->once())->method('getRepository')->willReturn($mockedEntityRepository);
     $result = $sut->get($recordId);
     $this->assertEquals($recordId, $result->getRecordId());
 }
Example #2
0
 public function testExecuteActionCallCustomerServiceStore()
 {
     $entity = 'a customer';
     $customerDto = new CustomerDto();
     $customerDto->setDeskCompanyId(1);
     /** @var \PHPUnit_Framework_MockObject_MockObject|\DeskModule\Queue\Marshal\Customer\JsonToCustomerDto $marshaller */
     $marshaller = $this->getService()->getJsonToCustomerMarshaller();
     $marshaller->expects($this->once())->method('marshall')->with($entity)->will($this->returnValue($customerDto));
     $action = new ActionModel();
     $action->setAction(ActionModel::ACTION_SYNC)->setEntityType(ActionModel::ENTITY_TYPE_CUSTOMER)->setEntity($entity);
     /** @var \PHPUnit_Framework_MockObject_MockObject|\DeskModule\Customer\Customer $customerService */
     $customerService = $this->getService()->getCustomerService();
     $customerService->expects($this->once())->method('store')->with($customerDto);
     $this->getService()->setCurrentAction($action);
     Reflection::invoke($this->getService(), 'executeAction');
 }