Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / media / tests / src / FunctionalJavascript / MediaUiJavascriptTest.php
index 981da61d59abe21dcc6c71776fdb5adc48d265d2..a00a3c20100c03142cca6b3bb653e216c5847f69 100644 (file)
@@ -38,11 +38,6 @@ class MediaUiJavascriptTest extends MediaJavascriptTestBase {
     parent::setUp();
     $this->drupalPlaceBlock('local_actions_block');
     $this->drupalPlaceBlock('local_tasks_block');
-
-    // We need to test without any default configuration in place.
-    // @TODO: Remove this as part of https://www.drupal.org/node/2883813.
-    MediaType::load('file')->delete();
-    MediaType::load('image')->delete();
   }
 
   /**
@@ -68,6 +63,10 @@ class MediaUiJavascriptTest extends MediaJavascriptTestBase {
     $this->assertJsCondition("jQuery('.form-item-source-configuration-test-config-value').length > 0;");
     $page->fillField('description', $description);
     $page->pressButton('Save');
+    // The wait prevents intermittent test failures.
+    $result = $assert_session->waitForLink('Add media type');
+    $this->assertNotEmpty($result);
+    $assert_session->addressEquals('admin/structure/media');
     $assert_session->pageTextContains('The media type ' . $name . ' has been added.');
     $this->drupalGet('admin/structure/media');
     $assert_session->pageTextContains($name);
@@ -139,6 +138,10 @@ class MediaUiJavascriptTest extends MediaJavascriptTestBase {
     $page->uncheckField('options[status]');
     $page->checkField('options[queue_thumbnail_downloads]');
     $page->pressButton('Save');
+    // The wait prevents intermittent test failures.
+    $result = $assert_session->waitForLink('Add media type');
+    $this->assertNotEmpty($result);
+    $assert_session->addressEquals('admin/structure/media');
     $assert_session->pageTextContains("The media type $new_name has been updated.");
 
     // Test if edit worked and if new field values have been saved as expected.
@@ -157,15 +160,15 @@ class MediaUiJavascriptTest extends MediaJavascriptTestBase {
     $loaded_media_type = $this->container->get('entity_type.manager')
       ->getStorage('media_type')
       ->load($this->testMediaType->id());
-    $this->assertEquals($loaded_media_type->id(), $this->testMediaType->id());
-    $this->assertEquals($loaded_media_type->label(), $new_name);
-    $this->assertEquals($loaded_media_type->getDescription(), $new_description);
-    $this->assertEquals($loaded_media_type->getSource()->getPluginId(), 'test');
-    $this->assertEquals($loaded_media_type->getSource()->getConfiguration()['test_config_value'], 'This is new config value.');
+    $this->assertSame($loaded_media_type->id(), $this->testMediaType->id());
+    $this->assertSame($loaded_media_type->label(), $new_name);
+    $this->assertSame($loaded_media_type->getDescription(), $new_description);
+    $this->assertSame($loaded_media_type->getSource()->getPluginId(), 'test');
+    $this->assertSame($loaded_media_type->getSource()->getConfiguration()['test_config_value'], 'This is new config value.');
     $this->assertTrue($loaded_media_type->shouldCreateNewRevision());
     $this->assertTrue($loaded_media_type->thumbnailDownloadsAreQueued());
     $this->assertFalse($loaded_media_type->getStatus());
-    $this->assertEquals($loaded_media_type->getFieldMap(), ['attribute_1' => 'name']);
+    $this->assertSame($loaded_media_type->getFieldMap(), ['attribute_1' => 'name']);
 
     // We need to clear the statically cached field definitions to account for
     // fields that have been created by API calls in this test, since they exist
@@ -188,7 +191,7 @@ class MediaUiJavascriptTest extends MediaJavascriptTestBase {
 
     // Test that the system for preventing the deletion of media types works
     // (they cannot be deleted if there is media content of that type/bundle).
-    $media_type2 = $this->createMediaType();
+    $media_type2 = $this->createMediaType('test');
     $label2 = $media_type2->label();
     $media = Media::create(['name' => 'lorem ipsum', 'bundle' => $media_type2->id()]);
     $media->save();