public function UserDataCdfAttributeTest::testPopulateUserNameAttribute in Acquia Content Hub 8.2
Tests username attribute population.
@dataProvider populateUserNameAttributeProvider
Parameters
array $data: Data.
File
- tests/
src/ Unit/ EventSubscriber/ CdfAttributes/ UserDataCdfAttributeTest.php, line 63
Class
- UserDataCdfAttributeTest
- Tests the user data cdf attribute.
Namespace
Drupal\Tests\acquia_contenthub\Unit\EventSubscriber\CdfAttributesCode
public function testPopulateUserNameAttribute(array $data) {
/** @var \Drupal\user\UserInterface $entity */
$entity = $this
->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMockForAbstractClass();
$entity
->method('label')
->willReturn($data);
$entity
->method('getEntityTypeId')
->willReturn('user');
$entity
->method('uuid')
->willReturn('3f0b403c-4093-4caa-ba78-37df21125f09');
$wrapper = new DependentEntityWrapper($entity);
$event = new CdfAttributesEvent($this->cdf, $entity, $wrapper);
$this->dispatcher
->dispatch(AcquiaContentHubEvents::POPULATE_CDF_ATTRIBUTES, $event);
$attribute = $event
->getCdf()
->getAttribute('username');
$this
->assertEquals(CDFAttribute::TYPE_STRING, $attribute
->getType());
$this
->assertArrayEquals($attribute
->getValue(), [
CDFObject::LANGUAGE_UNDETERMINED => $data,
]);
}