PathMediaFormTest.php in Drupal 9
File
core/modules/path/tests/src/Functional/PathMediaFormTest.php
View source
<?php
namespace Drupal\Tests\path\Functional;
use Drupal\media\Entity\MediaType;
class PathMediaFormTest extends PathTestBase {
protected static $modules = [
'media',
'media_test_source',
];
protected $defaultTheme = 'classy';
protected function setUp() : void {
parent::setUp();
$web_user = $this
->drupalCreateUser([
'create media',
'create url aliases',
]);
$this
->drupalLogin($web_user);
}
public function testMediaForm() {
$assert_session = $this
->assertSession();
$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);
$assert_session
->elementContains('css', '.form-type-vertical-tabs #edit-path-0 summary', 'URL alias');
$assert_session
->fieldExists('path[0][alias]');
\Drupal::service('entity_display.repository')
->getFormDisplay('media', $media_type_id, 'default')
->removeComponent('path')
->save();
$this
->drupalGet('media/add/' . $media_type_id);
$assert_session
->elementNotExists('css', '.form-type-vertical-tabs #edit-path-0');
$assert_session
->fieldNotExists('path[0][alias]');
}
}