public function HashCdfAttributeTest::testOnPopulateAttributes in Acquia Content Hub 8.2
Tests 'hash' attribute population.
@dataProvider onPopulateAttributesProvider
Parameters
string $type: Type.
string $uuid: Uuid.
string $created: Created date.
string $modified: Modified date.
string $origin: Origin.
array $metadata: Metadata.
File
- tests/
src/ Unit/ EventSubscriber/ CdfAttributes/ HashCdfAttributeTest.php, line 61
Class
- HashCdfAttributeTest
- Tests hashing of cdf attributes.
Namespace
Drupal\Tests\acquia_contenthub\Unit\EventSubscriber\CdfAttributesCode
public function testOnPopulateAttributes(string $type, string $uuid, string $created, string $modified, string $origin, array $metadata) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this
->getMockBuilder(ContentEntityInterface::class)
->disableOriginalConstructor()
->getMock();
$entity
->method('uuid')
->willReturn($uuid);
$wrapper = new DependentEntityWrapper($entity);
/** @var \Acquia\ContentHubClient\CDF\CDFObject $cdf */
$cdf = new CDFObject($type, $uuid, $created, $modified, $origin, $metadata);
$event = new CdfAttributesEvent($cdf, $entity, $wrapper);
$this->dispatcher
->dispatch(AcquiaContentHubEvents::POPULATE_CDF_ATTRIBUTES, $event);
$hash_attribute = $event
->getCdf()
->getAttribute('hash');
$this
->assertEquals(CDFAttribute::TYPE_STRING, $hash_attribute
->getType());
$expected = [
CDFObject::LANGUAGE_UNDETERMINED => $wrapper
->getHash(),
];
$this
->assertArrayEquals($expected, $hash_attribute
->getValue());
}