public function PathMediaFormTest::testMediaForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/path/tests/src/Functional/PathMediaFormTest.php \Drupal\Tests\path\Functional\PathMediaFormTest::testMediaForm()
Tests the media form UI.
File
- core/
modules/ path/ tests/ src/ Functional/ PathMediaFormTest.php, line 38
Class
- PathMediaFormTest
- Tests the path media form UI.
Namespace
Drupal\Tests\path\FunctionalCode
public function testMediaForm() {
$assert_session = $this
->assertSession();
// Create media type.
$media_type_id = 'foo';
$media_type = MediaType::create([
'id' => $media_type_id,
'label' => $media_type_id,
'source' => 'test',
'source_configuration' => [],
'field_map' => [],
'new_revision' => FALSE,
]);
$media_type
->save();
$this
->drupalGet('media/add/' . $media_type_id);
// Make sure we have a vertical tab fieldset and 'Path' field.
$assert_session
->elementContains('css', '.form-type-vertical-tabs #edit-path-0 summary', 'URL alias');
$assert_session
->fieldExists('path[0][alias]');
// Disable the 'Path' field for this content type.
\Drupal::service('entity_display.repository')
->getFormDisplay('media', $media_type_id, 'default')
->removeComponent('path')
->save();
$this
->drupalGet('media/add/' . $media_type_id);
// See if the whole fieldset is gone now.
$assert_session
->elementNotExists('css', '.form-type-vertical-tabs #edit-path-0');
$assert_session
->fieldNotExists('path[0][alias]');
}