コード例 #1
0
ファイル: ServiceTest.php プロジェクト: kkucera/XssModule
 /**
  * @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);
 }
コード例 #2
0
 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']);
 }
コード例 #3
0
 /**
  * @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);
 }