public function PublisherSubscriberStatusCdfAttributeTest::testOnPopulateAttributes in Acquia Content Hub 8.2
Tests 'subscriber' and 'publisher' attributes population.
File
- tests/
src/ Unit/ EventSubscriber/ CdfAttributes/ PublisherSubscriberStatusCdfAttributeTest.php, line 52
Class
- PublisherSubscriberStatusCdfAttributeTest
- Tests the PublisherSubscriberStatusCdfAttribute.
Namespace
Drupal\Tests\acquia_contenthub\Unit\EventSubscriber\CdfAttributesCode
public function testOnPopulateAttributes() {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$isPublisher = TRUE;
$isSubscriber = FALSE;
$cdf = $this
->getMockBuilder(ClientCDFObject::class)
->disableOriginalConstructor()
->getMock();
$publiherCdfAttribute = $this
->getMockBuilder(CDFAttribute::class)
->disableOriginalConstructor()
->getMock();
$subscriberCdfAttribute = $this
->getMockBuilder(CDFAttribute::class)
->disableOriginalConstructor()
->getMock();
$publiherCdfAttribute
->method('getType')
->willReturn(CDFAttribute::TYPE_BOOLEAN);
$publiherCdfAttribute
->method('getValue')
->willReturn($isPublisher);
$subscriberCdfAttribute
->method('getType')
->willReturn(CDFAttribute::TYPE_BOOLEAN);
$subscriberCdfAttribute
->method('getValue')
->willReturn($isSubscriber);
$cdf
->method('getAttribute')
->will($this
->returnValueMap([
[
'publisher',
$publiherCdfAttribute,
],
[
'subscriber',
$subscriberCdfAttribute,
],
]));
$event = $this
->getMockBuilder(BuildClientCdfEvent::class)
->disableOriginalConstructor()
->getMock();
$event
->method('isPropagationStopped')
->willReturn(TRUE);
$event
->method('getCdf')
->willReturn($cdf);
$this->dispatcher
->dispatch(AcquiaContentHubEvents::BUILD_CLIENT_CDF, $event);
$cdf = $event
->getCdf();
$publisher = $cdf
->getAttribute('publisher');
$subscriber = $cdf
->getAttribute('subscriber');
$this
->assertEquals(CDFAttribute::TYPE_BOOLEAN, $publisher
->getType());
$this
->assertEquals($isPublisher, $publisher
->getValue());
$this
->assertEquals(CDFAttribute::TYPE_BOOLEAN, $subscriber
->getType());
$this
->assertEquals($isSubscriber, $subscriber
->getValue());
}