You are here

public function MediaTypeCreationTest::testMediaTypeCreationForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Functional/MediaTypeCreationTest.php \Drupal\Tests\media\Functional\MediaTypeCreationTest::testMediaTypeCreationForm()

Tests the media type creation form with only the mandatory options.

File

core/modules/media/tests/src/Functional/MediaTypeCreationTest.php, line 29

Class

MediaTypeCreationTest
Ensures that media UI works correctly without JavaScript.

Namespace

Drupal\Tests\media\Functional

Code

public function testMediaTypeCreationForm() {
  $machine_name = mb_strtolower($this
    ->randomMachineName());
  $this
    ->drupalGet('/admin/structure/media/add');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->fieldExists('label')
    ->setValue($this
    ->randomString());
  $this
    ->assertSession()
    ->fieldExists('id')
    ->setValue($machine_name);
  $this
    ->assertSession()
    ->selectExists('source')
    ->selectOption('test');
  $this
    ->assertSession()
    ->buttonExists('Save')
    ->press();
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->fieldValueEquals('Test config value', 'This is default value.');
  $this
    ->assertSession()
    ->buttonExists('Save')
    ->press();
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->addressEquals('admin/structure/media');
  $this
    ->assertInstanceOf(MediaType::class, MediaType::load($machine_name));
}