You are here

public function MediaImageModifyTest::testImageEdit in Thunder 8.3

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.4 tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  4. 6.2.x tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  5. 6.0.x tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()
  6. 6.1.x tests/src/FunctionalJavascript/MediaImageModifyTest.php \Drupal\Tests\thunder\FunctionalJavascript\MediaImageModifyTest::testImageEdit()

Test Image modifications (edit fields).

File

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

Class

MediaImageModifyTest
Tests the Image media modification.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function testImageEdit() {

  // Media ID used for testing.
  $mediaId = 9;
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->drupalGet("media/{$mediaId}/edit");
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $page
    ->fillField('name[0][value]', "Media {$mediaId}");
  $page
    ->fillField('field_image[0][alt]', "Media {$mediaId} Alt Text");
  $page
    ->fillField('field_image[0][title]', "Media {$mediaId} 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 {$mediaId} Copyright");
  $page
    ->fillField('field_source[0][value]', "Media {$mediaId} Source");
  $this
    ->fillCkEditor('#edit-field-description-0-value', "Media {$mediaId} Description");
  $this
    ->createScreenshot($this
    ->getScreenshotFolder() . '/MediaImageModifyTest_BeforeImageEditSave_' . date('Ymd_His') . '.png');
  $this
    ->clickSave();

  // Edit media and check are fields correct.
  $this
    ->drupalGet("media/{$mediaId}/edit");
  $this
    ->createScreenshot($this
    ->getScreenshotFolder() . '/MediaImageModifyTest_AfterImageEdit_' . date('Ymd_His') . '.png');
  $this
    ->assertSession()
    ->fieldValueEquals('name[0][value]', "Media {$mediaId}");
  $this
    ->assertSession()
    ->fieldValueEquals('field_image[0][alt]', "Media {$mediaId} Alt Text");
  $this
    ->assertSession()
    ->fieldValueEquals('field_image[0][title]', "Media {$mediaId} 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 {$mediaId} Copyright");
  $this
    ->assertSession()
    ->fieldValueEquals('field_source[0][value]', "Media {$mediaId} Source");
  $this
    ->assertSession()
    ->fieldValueEquals('field_description[0][value]', "<p>Media {$mediaId} Description</p>");
}