Example #1
0
 public function testTriggerSetsTarget()
 {
     $event = new Event();
     $this->assertNull($event->getTarget());
     Reflection::invoke($this->sut, 'trigger', array($event));
     $this->assertSame($this->sut, $event->getTarget());
 }
 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']);
 }
Example #3
0
 public function testMarshallValidatedItem()
 {
     $company = $this->getCompany()->setId(1)->setName('foo');
     $this->getMarshaller();
     $json = Reflection::invoke($this->getMarshaller(), 'marshallValidatedItem', array($company));
     $result = json_decode($json, true);
     $this->assertEquals($company->getId(), $result['id']);
     $this->assertEquals($company->getName(), $result['name']);
 }
Example #4
0
 public function testPersist()
 {
     /** @var ConsumerService|PHPUnit_Framework_MockObject_MockObject $sut */
     $sut = $this->getMock('DeskModule\\Queue\\Consumer\\Service', array('getDefaultMasterSlave'));
     $mockedEntityRepository = $this->getMock('\\Doctrine\\ORM\\EntityManager', array(), array(), '', false);
     $mockedEntityRepository->expects($this->once())->method('persist')->with(self::$consumer);
     $mockedEntityRepository->expects($this->once())->method('flush')->with(self::$consumer);
     $mockedAdapter = $this->getMock('EMRCore\\DoctrineConnector\\Adapter\\Adapter', array('getEntityManager'), array(), '', false);
     $mockedAdapter->expects($this->once())->method('getEntityManager')->willReturn($mockedEntityRepository);
     $sut->expects($this->once())->method('getDefaultMasterSlave')->willReturn($mockedAdapter);
     Reflection::invoke($sut, 'persist', array(self::$consumer));
 }
 public function testMarshallValidatedItem()
 {
     $customerDto = $this->getCustomerDto()->setWebptId(1)->setDeskId('desk_1')->setEmail('*****@*****.**')->setDeskCompanyId(23)->setFirstName('mr')->setLastName('anderson')->setUserType('guyish');
     $this->getMarshaller();
     $json = Reflection::invoke($this->getMarshaller(), 'marshallValidatedItem', array($customerDto));
     $result = json_decode($json, true);
     $this->assertEquals($customerDto->getWebptId(), $result['webptId']);
     $this->assertEquals($customerDto->getDeskId(), $result['deskId']);
     $this->assertEquals($customerDto->getEmail(), $result['email']);
     $this->assertEquals($customerDto->getDeskCompanyId(), $result['deskCompanyId']);
     $this->assertEquals($customerDto->getFirstName(), $result['firstName']);
     $this->assertEquals($customerDto->getLastName(), $result['lastName']);
     $this->assertEquals($customerDto->getUserType(), $result['userType']);
 }
 public function testMarshall()
 {
     $id = '432';
     /** @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($id);
     $this->assertInstanceOf('DeskModule\\Client\\ClientCommand', $result);
     $command = $result->getCommand();
     $this->assertEquals($id, $command->get('id'));
 }
Example #7
0
 public function testGetThrottleSecondsReturnsMinSecondsPassedWhenValueIsHigherThanSetClassMember()
 {
     $expectedSeconds = 1;
     Reflection::set($this->getService(), 'throttleSeconds', 2);
     $actualSeconds = $this->getService()->getThrottleSeconds($expectedSeconds);
     $this->assertEquals($expectedSeconds, $actualSeconds);
 }
 public function testGetMaxItemsToConsume()
 {
     $controller = $this->getController();
     $result = Reflection::invoke($controller, 'getMaxItemsToConsume');
     $this->assertEquals(self::MAX_TO_CONSUME, $result);
 }