Example #1
0
 /**
  * @return CustomerDto
  */
 private function getCustomerDto()
 {
     static $id = 0;
     $id++;
     $customerDto = new CustomerDto();
     return $customerDto->setFirstName('FirstName_' . $id)->setLastName('LastName_' . $id)->setUserType('UserType_' . $id)->setEmail('email_' . $id)->setWebptCompanyId('webptCompanyId_' . $id)->setDeskCompanyId('deskCompanyId_' . $id)->setDeskId('deskId_' . $id)->setWebptId('webptId' . $id);
 }
 public function testMarshall()
 {
     $customerDto = new CustomerDto();
     $customerDto->setDeskId(1111111);
     $customerDto->setWebptId(232);
     $customerDto->setFirstName('Imma');
     $customerDto->setLastName('Tool');
     $customerDto->setEmail('*****@*****.**');
     $customerDto->setDeskCompanyId(99);
     $customerDto->setUserType('short');
     /** @var \PHPUnit_Framework_MockObject_MockObject|\DeskModule\Client\ClientCommand $clientCommand */
     $clientCommand = $this->getMock('\\DeskModule\\Client\\ClientCommand', array('prepareOperation'), array(), '', false);
     $clientCommand->setCommand(new EmbeddedCommand());
     $clientCommand->expects($this->once())->method('prepareOperation')->with(Reflection::invoke($this->marshaller, 'getOperation'))->will($this->returnValue($clientCommand));
     /** @var \PHPUnit_Framework_MockObject_MockObject $factory */
     $factory = $this->getMock('DeskModule\\Client\\Factory');
     $factory->expects($this->once())->method('get')->will($this->returnValue($clientCommand));
     $this->marshaller->setClientFactory($factory);
     /** @var \DeskModule\Client\ClientCommand $result */
     $result = $this->marshaller->marshall($customerDto);
     $this->assertInstanceOf('\\DeskModule\\Client\\ClientCommand', $result);
     $command = $clientCommand->getCommand();
     $this->assertEquals($customerDto->getDeskId(), $command->get('id'));
     $this->assertEquals($customerDto->getWebptId(), $command->get('external_id'));
     $this->assertEquals($customerDto->getFirstName(), $command->get('first_name'));
     $this->assertEquals($customerDto->getLastName(), $command->get('last_name'));
     $this->assertEquals($customerDto->getDeskCompanyId(), $command->get('company_id'));
     $emails = $command->get('emails');
     $this->assertCount(1, $emails);
     $this->assertEquals($customerDto->getEmail(), $emails[0]->value);
     $customFields = $command->get('custom_fields');
     $this->assertEquals($customerDto->getUserType(), $customFields['user_type']);
 }
 /**
  * @expectedException \DeskModule\Client\Customer\Exception\CreateFailed
  */
 public function testMarshallThrowsExceptionWhenNonNumericDeskCompanyId()
 {
     $customerDto = new CustomerDto();
     $customerDto->setWebptId(232);
     $customerDto->setFirstName('Imma');
     $customerDto->setLastName('Tool');
     $customerDto->setEmail('*****@*****.**');
     $customerDto->setDeskCompanyId('desk_99');
     $customerDto->setUserType('short');
     /** @var \Desk\Relationship\Resource\EmbeddedCommand $result */
     $this->marshaller->marshall($customerDto);
 }
Example #4
0
 public function testNotCreateDueToInvalidResponse()
 {
     $customer = new CustomerDto();
     $customer->setWebptId($webptId = $this->getId());
     /** @var \PHPUnit_Framework_MockObject_MockObject $mapService */
     $mapService = $this->sut->getCustomerMapService();
     $mapService->expects($this->once())->method('getByWebptId')->with($webptId)->will($this->returnValue(null));
     $clientCommand = $this->getMock('\\DeskModule\\Client\\ClientCommand', array(), array(), '', false);
     /** @var \PHPUnit_Framework_MockObject_MockObject|\DeskModule\Client\Customer\Customer $clientService */
     $clientService = $this->getMockBuilder('DeskModule\\Client\\Customer\\Customer')->setMethods(array('getCustomerToCreateCommandMarshaller'))->getMock();
     $clientService->expects($this->once())->method('getCustomerToCreateCommandMarshaller')->will($this->returnValue($marshaller = $this->getMock('\\DeskModule\\Client\\Customer\\Marshaller\\CustomerToCreateCommand')));
     $clientService->setCustomerClientEventManager(new Manager());
     $this->sut->setCustomerClientService($clientService);
     $marshaller->expects($this->once())->method('marshall')->with($customer)->will($this->returnValue($clientCommand));
     $clientCommand->expects($this->once())->method('execute')->will($this->returnValue($this->getMock('\\Desk\\Relationship\\Resource\\Model')));
     //$clientService->setLogger($this->getMock('\Logger', array(), array(), '', false));
     // Ensure map was not created.
     $mapService->expects($this->never())->method('create');
     $this->sut->store($customer);
 }
Example #5
0
 /**
  * @expectedException \DeskModule\Queue\Action\Exception\InvalidEntityException
  */
 public function testLoadDeskCompanyIdThrowsInvalidEntityWhenNoCompanyMap()
 {
     $customerDto = new CustomerDto();
     $customerDto->setWebptCompanyId($webptCompanyId = 321);
     $companyMapService = $this->getMock('DeskModule\\Map\\Company');
     $companyMapService->expects($this->once())->method('getByWebptId')->with($webptCompanyId)->will($this->returnValue(null));
     /** @var \PHPUnit_Framework_MockObject_MockObject|\DeskModule\Company\Company $companyService */
     $companyService = $this->getService()->getCompanyService();
     $companyService->expects($this->once())->method('getCompanyMapService')->will($this->returnValue($companyMapService));
     Reflection::invoke($this->getService(), 'loadDeskCompanyId', array($customerDto));
 }