class PathMediaFormTest
Same name and namespace in other branches
- 11.x core/modules/path/tests/src/Functional/PathMediaFormTest.php \Drupal\Tests\path\Functional\PathMediaFormTest
- 10 core/modules/path/tests/src/Functional/PathMediaFormTest.php \Drupal\Tests\path\Functional\PathMediaFormTest
- 8.9.x core/modules/path/tests/src/Functional/PathMediaFormTest.php \Drupal\Tests\path\Functional\PathMediaFormTest
Tests the path media form UI.
@group path
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\path\Functional\PathTestBase uses \Drupal\Tests\Traits\Core\PathAliasTestTrait extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\path\Functional\PathMediaFormTest extends \Drupal\Tests\path\Functional\PathTestBase
- class \Drupal\Tests\path\Functional\PathTestBase uses \Drupal\Tests\Traits\Core\PathAliasTestTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of PathMediaFormTest
File
-
core/
modules/ path/ tests/ src/ Functional/ PathMediaFormTest.php, line 12
Namespace
Drupal\Tests\path\FunctionalView source
class PathMediaFormTest extends PathTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'media',
'media_test_source',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Create test user and log in.
$web_user = $this->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', '.js-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', '.js-form-type-vertical-tabs #edit-path-0');
$assert_session->fieldNotExists('path[0][alias]');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.