public function MediaEntityImageTest::testMediaEntityImage in Acquia Content Hub 8
Tests a Media entity CDF.
File
- tests/
src/ Functional/ MediaEntityImageTest.php, line 70
Class
- MediaEntityImageTest
- Test that Acquia Content Hub produces a correct Media Entity CDF.
Namespace
Drupal\Tests\acquia_contenthub\FunctionalCode
public function testMediaEntityImage() {
$this
->drupalLogin($this->adminUser);
// Create the Image Media Entity.
$this
->drupalGet('media/add/image');
$this
->assertResponse(200);
$edit = [
'name[0][value]' => 'Media Test',
];
$this
->drupalPostForm(NULL, $edit, $this
->t('Save and publish'));
$this
->configureContentHubContentTypes('media', [
'image',
]);
$this
->setRoleFor($this->adminRole);
// Render CDF as admin to avoid having to set permissions for media entity.
$output = $this
->drupalGetCdf('acquia-contenthub-cdf/media/1', [
'query' => [
'include_references' => 'true',
],
]);
$this
->assertResponse(200);
$this
->assertEqual($output['entities']['0']['attributes']['bundle']['type'], 'array<string>');
$this
->assertEqual($output['entities']['0']['attributes']['bundle']['value']['en'][0], 'image');
$this
->assertEqual($output['entities']['0']['attributes']['name']['value']['en'][0], 'Media Test');
$this
->assertNotNull($output['entities']['0']['assets'][0]['url']);
$this
->assertNotNull($output['entities']['0']['assets'][0]['replace-token']);
$thumbnail = $output['entities']['0']['attributes']['thumbnail']['value']['en'][0];
$thumbnail = Json::decode($thumbnail);
$this
->assertEqual($thumbnail['title'], 'Media Test');
}