3 namespace Drupal\Tests\path\Functional;
5 use Drupal\media\Entity\MediaType;
8 * Tests the path media form UI.
12 class PathMediaFormTest extends PathTestBase {
17 public static $modules = ['media', 'media_test_source'];
22 protected function setUp() {
25 // Create test user and log in.
26 $web_user = $this->drupalCreateUser(['create media', 'create url aliases']);
27 $this->drupalLogin($web_user);
31 * Tests the media form UI.
33 public function testMediaForm() {
34 $assert_session = $this->assertSession();
37 $media_type_id = 'foo';
38 $media_type = MediaType::create([
39 'id' => $media_type_id,
40 'label' => $media_type_id,
42 'source_configuration' => [],
44 'new_revision' => FALSE,
48 $this->drupalGet('media/add/' . $media_type_id);
50 // Make sure we have a vertical tab fieldset and 'Path' field.
51 $assert_session->elementContains('css', '.form-type-vertical-tabs #edit-path-0 summary', 'URL alias');
52 $assert_session->fieldExists('path[0][alias]');
54 // Disable the 'Path' field for this content type.
55 entity_get_form_display('media', $media_type_id, 'default')
56 ->removeComponent('path')
59 $this->drupalGet('media/add/' . $media_type_id);
61 // See if the whole fieldset is gone now.
62 $assert_session->elementNotExists('css', '.form-type-vertical-tabs #edit-path-0');
63 $assert_session->fieldNotExists('path[0][alias]');