public function MediaUiFunctionalTest::testMediaCollectionRoute in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::testMediaCollectionRoute()
Test the media collection route.
File
- core/
modules/ media/ tests/ src/ Functional/ MediaUiFunctionalTest.php, line 540
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")');
}