public function setUp() { $this->registry = $this->getMock('Symfony\\Bridge\\Doctrine\\RegistryInterface'); $this->settingProvider = $this->getMockBuilder('OroCRM\\Bundle\\ChannelBundle\\Provider\\SettingsProvider')->disableOriginalConstructor()->getMock(); $this->event = $this->getMockBuilder('OroCRM\\Bundle\\ChannelBundle\\Event\\ChannelSaveEvent')->disableOriginalConstructor()->getMock(); $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->entity = new Channel(); $this->integration = new Integration(); $this->entity->setDataSource($this->integration); }
/** * Returns built channel * * @SuppressWarnings(PHPMD.NPathComplexity) * * @return Channel */ public function getChannel() { $type = $this->getDefaultType(); $name = $this->getDefaultName($type); $identity = $this->settingsProvider->getCustomerIdentityFromConfig($type); if ($this->populateEntities) { $this->entities = $this->settingsProvider->getEntitiesByChannelType($type); } $this->addEntity($identity, true); $owner = $this->owner; if (!$owner) { $owner = $this->getDefaultOrganization(); } $this->channel->setChannelType($type); $this->channel->setName($name); $this->channel->setOwner($owner); $this->channel->setCustomerIdentity($identity); $this->channel->setEntities($this->entities); $this->channel->setStatus($this->status); $this->channel->setDataSource($this->dataSource); if (null !== $this->createdAt) { // set created at only whn not nullable, otherwise update scenario will fail $this->channel->setCreatedAt($this->createdAt); } return $this->channel; }
/** * @dataProvider dataProvider */ public function testOnChannelStatusChange($status, $isEnabled) { $integration = new Integration(); $entity = new Channel(); $entity->setStatus($status); $entity->setDataSource($integration); $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em)); $this->em->expects($this->once())->method('persist')->with($integration); $this->em->expects($this->once())->method('flush'); $listener = new ChangeChannelStatusListener($this->registry); $listener->onChannelStatusChange(new ChannelChangeStatusEvent($entity)); $this->assertEquals($integration->getEnabled(), $isEnabled); }
/** * Returns built channel * * @SuppressWarnings(PHPMD.NPathComplexity) * * @return Channel */ public function getChannel() { $type = $this->getDefaultType(); $name = $this->getDefaultName($type); $identity = $this->settingsProvider->getCustomerIdentityFromConfig($type); if ($this->populateEntities) { $this->entities = $this->settingsProvider->getEntitiesByChannelType($type); } $this->addEntity($identity, true); $owner = $this->owner; if (!$owner) { $owner = $this->getDefaultOrganization(); } $this->channel->setChannelType($type); $this->channel->setName($name); $this->channel->setOwner($owner); $this->channel->setCustomerIdentity($identity); $this->channel->setEntities($this->entities); $this->channel->setStatus($this->status); $this->channel->setDataSource($this->dataSource); return $this->channel; }