X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fpath%2Ftests%2Fsrc%2FFunctional%2FPathMediaFormTest.php;fp=web%2Fcore%2Fmodules%2Fpath%2Ftests%2Fsrc%2FFunctional%2FPathMediaFormTest.php;h=3a9690081049c573017a1a45dd18551c39800c25;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/path/tests/src/Functional/PathMediaFormTest.php b/web/core/modules/path/tests/src/Functional/PathMediaFormTest.php new file mode 100644 index 000000000..3a9690081 --- /dev/null +++ b/web/core/modules/path/tests/src/Functional/PathMediaFormTest.php @@ -0,0 +1,66 @@ +drupalCreateUser(['create media', 'create url aliases']); + $this->drupalLogin($web_user); + } + + /** + * Tests the media form UI. + */ + 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. + entity_get_form_display('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]'); + } + +}