public function MediaUiFunctionalTest::testMediaCollectionRoute in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::testMediaCollectionRoute()
- 9 core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::testMediaCollectionRoute()
Tests the media collection route.
File
- core/
modules/ media/ tests/ src/ Functional/ MediaUiFunctionalTest.php, line 554
Class
- MediaUiFunctionalTest
- Ensures that media UI works correctly.
Namespace
Drupal\Tests\media\FunctionalCode
public function testMediaCollectionRoute() {
/** @var \Drupal\Core\Entity\EntityStorageInterface $media_storage */
$media_storage = $this->container
->get('entity_type.manager')
->getStorage('media');
$this->container
->get('module_installer')
->uninstall([
'views',
]);
// Create a media type and media item.
$media_type = $this
->createMediaType('test');
$media = $media_storage
->create([
'bundle' => $media_type
->id(),
'name' => 'Unnamed',
]);
$media
->save();
$this
->drupalGet($media
->toUrl('collection'));
$assert_session = $this
->assertSession();
// Media list table exists.
$assert_session
->elementExists('css', 'th:contains("Media Name")');
$assert_session
->elementExists('css', 'th:contains("Type")');
$assert_session
->elementExists('css', 'th:contains("Operations")');
// Media item is present.
$assert_session
->elementExists('css', 'td:contains("Unnamed")');
}