You are here

public function MediaImageModifyTest::testImageEdit in Thunder 6.1.x

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  2. 8.2 tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  3. 8.3 tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  4. 8.4 tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  5. 6.2.x tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  6. 6.0.x tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()

Test Image modifications (edit fields).

File

tests/src/FunctionalJavascript/MediaImageModifyTest.php, line 60

Class

MediaImageModifyTest
Tests the Image media modification.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function testImageEdit() {
  $page = $this
    ->getSession()
    ->getPage();
  $media = $this
    ->loadMediaByUuid('f5f7fc5d-b2b8-426a-adf3-ee6aff6379da');
  $this
    ->drupalGet($media
    ->toUrl('edit-form'));
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $page
    ->fillField('name[0][value]', "Media {$media->id()}");
  $page
    ->fillField('field_image[0][alt]', "Media {$media->id()} Alt Text");
  $page
    ->fillField('field_image[0][title]', "Media {$media->id()} Title");
  $this
    ->setRawFieldValue('field_expires[0][value][date]', '2022-12-18');
  $this
    ->setRawFieldValue('field_expires[0][value][time]', '01:02:03');
  $page
    ->fillField('field_copyright[0][value]', "Media {$media->id()} Copyright");
  $page
    ->fillField('field_source[0][value]', "Media {$media->id()} Source");
  $this
    ->fillCkEditor('#edit-field-description-0-value', "Media {$media->id()} Description");
  $this
    ->createScreenshot($this
    ->getScreenshotFolder() . '/MediaImageModifyTest_BeforeImageEditSave_' . date('Ymd_His') . '.png');
  $this
    ->clickSave();

  // Edit media and check are fields correct.
  $this
    ->drupalGet($media
    ->toUrl('edit-form'));
  $this
    ->createScreenshot($this
    ->getScreenshotFolder() . '/MediaImageModifyTest_AfterImageEdit_' . date('Ymd_His') . '.png');
  $this
    ->assertSession()
    ->fieldValueEquals('name[0][value]', "Media {$media->id()}");
  $this
    ->assertSession()
    ->fieldValueEquals('field_image[0][alt]', "Media {$media->id()} Alt Text");
  $this
    ->assertSession()
    ->fieldValueEquals('field_image[0][title]', "Media {$media->id()} Title");
  $this
    ->assertSession()
    ->fieldValueEquals('field_expires[0][value][date]', '2022-12-18');
  $this
    ->assertSession()
    ->fieldValueEquals('field_expires[0][value][time]', '01:02:03');
  $this
    ->assertSession()
    ->fieldValueEquals('field_copyright[0][value]', "Media {$media->id()} Copyright");
  $this
    ->assertSession()
    ->fieldValueEquals('field_source[0][value]', "Media {$media->id()} Source");
  $this
    ->assertSession()
    ->fieldValueEquals('field_description[0][value]', "<p>Media {$media->id()} Description</p>");
}