function MediaStandardProfileTest::testMediaSources

Same name in other branches
  1. 9 core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php \Drupal\Tests\media\FunctionalJavascript\MediaStandardProfileTest::testMediaSources()
  2. 8.9.x core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php \Drupal\Tests\media\FunctionalJavascript\MediaStandardProfileTest::testMediaSources()
  3. 11.x core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php \Drupal\Tests\media\FunctionalJavascript\MediaStandardProfileTest::testMediaSources()

Tests all media sources in one method.

This prevents installing the standard profile for every test case and increases the performance of this test.

File

core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php, line 51

Class

MediaStandardProfileTest
Basic tests for Media configuration in the standard profile.

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

public function testMediaSources() : void {
    // This test currently frequently causes the SQLite database to lock, so
    // skip the test on SQLite until the issue can be resolved.
    // @todo https://www.drupal.org/project/drupal/issues/3273626
    if (Database::getConnection()->driver() === 'sqlite') {
        $this->markTestSkipped('Test frequently causes a locked database on SQLite');
    }
    $storage = FieldStorageConfig::create([
        'entity_type' => 'node',
        'field_name' => 'field_related_media',
        'type' => 'entity_reference',
        'settings' => [
            'target_type' => 'media',
        ],
    ]);
    $storage->save();
    FieldConfig::create([
        'field_storage' => $storage,
        'entity_type' => 'node',
        'bundle' => 'article',
        'label' => 'Related media',
        'settings' => [
            'handler_settings' => [
                'target_bundles' => [
                    'audio' => 'audio',
                    'document' => 'document',
                    'image' => 'image',
                    'remote_video' => 'remote_video',
                    'video' => 'video',
                ],
            ],
        ],
    ])->save();
    $display = EntityViewDisplay::load('node.article.default');
    $display->setComponent('field_related_media', [
        'type' => 'entity_reference_entity_view',
        'settings' => [
            'view_mode' => 'full',
        ],
    ])
        ->save();
    $this->audioTest();
    $this->documentTest();
    $this->imageTest();
    $this->remoteVideoTest();
    $this->videoTest();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.