Verified Commit b2c5ada3 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3272581 by danflanagan8: Image tests should not rely on Classy

parent 0a03e7b1
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public function testNumericStyleName() {
    ];
    $this->drupalGet('admin/config/media/image-styles/add');
    $this->submitForm($edit, 'Create new style');
    $this->assertSession()->pageTextContains("Style {$style_label} was created.");
    $this->assertSession()->statusMessageContains("Style {$style_label} was created.", 'status');
    $options = image_style_options();
    $this->assertArrayHasKey($style_name, $options);
  }
@@ -120,7 +120,7 @@ public function testStyle() {
    ];
    $this->drupalGet($admin_path . '/add');
    $this->submitForm($edit, 'Create new style');
    $this->assertSession()->pageTextContains("Style {$style_label} was created.");
    $this->assertSession()->statusMessageContains("Style {$style_label} was created.", 'status');

    // Ensure that the expected entity operations are there.
    $this->drupalGet($admin_path);
@@ -259,7 +259,7 @@ public function testStyle() {
    // Confirm that the form submission was successful.
    $this->assertSession()->statusCodeEquals(200);
    $image_crop_effect = $style->getEffect($uuids['image_crop']);
    $this->assertSession()->pageTextContains("The image effect {$image_crop_effect->label()} has been deleted.");
    $this->assertSession()->statusMessageContains("The image effect {$image_crop_effect->label()} has been deleted.", 'status');
    // Confirm that there is no longer a link to the effect.
    $this->assertSession()->linkByHrefNotExists($style_path . '/effects/' . $uuids['image_crop'] . '/delete');
    // Refresh the image style information and verify that the effect was
@@ -359,7 +359,7 @@ public function testStyleReplacement() {
    ];
    $this->drupalGet($style_path . $style_name);
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Changes to the style have been saved.');
    $this->assertSession()->statusMessageContains('Changes to the style have been saved.', 'status');
    $this->drupalGet('node/' . $nid);

    // Reload the image style using the new name.
@@ -372,7 +372,7 @@ public function testStyleReplacement() {
    ];
    $this->drupalGet($style_path . $new_style_name . '/delete');
    $this->submitForm($edit, 'Delete');
    $this->assertSession()->pageTextContains("The image style {$new_style_label} has been deleted.");
    $this->assertSession()->statusMessageContains("The image style {$new_style_label} has been deleted.", 'status');

    $replacement_style = ImageStyle::load('thumbnail');
    $this->drupalGet('node/' . $nid);
+11 −11
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class ImageDimensionsTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  protected $profile = 'testing';

@@ -79,7 +79,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" width="120" height="60" alt="" loading="lazy" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="120" height="60" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -100,7 +100,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" width="60" height="120" alt="" loading="lazy" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="60" height="120" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -122,7 +122,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" width="45" height="90" alt="" loading="lazy" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="45" height="90" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -144,7 +144,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" width="45" height="90" alt="" loading="lazy" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="45" height="90" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -162,7 +162,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" width="45" height="90" alt="" loading="lazy" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="45" height="90" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -183,7 +183,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" alt="" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" alt="" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -202,7 +202,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" width="30" height="30" alt="" loading="lazy" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="30" height="30" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -248,7 +248,7 @@ public function testImageDimensions() {

    $style->addImageEffect($effect);
    $style->save();
    $this->assertEquals('<img src="' . $url . '" alt="" class="image-style-test" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" alt="" />', $this->getImageTag($variables));

    // Test URI dependent image effect.
    $style = ImageStyle::create(['name' => 'test_uri', 'label' => 'Test URI']);
@@ -269,7 +269,7 @@ public function testImageDimensions() {
    // PNG original image. Should be resized to 100x100.
    $generated_uri = 'public://styles/test_uri/public/' . $file_system->basename($original_uri);
    $url = \Drupal::service('file_url_generator')->transformRelative($style->buildUrl($original_uri));
    $this->assertEquals('<img src="' . $url . '" width="100" height="100" alt="" loading="lazy" class="image-style-test-uri" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="100" height="100" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
@@ -283,7 +283,7 @@ public function testImageDimensions() {
    $generated_uri = 'public://styles/test_uri/public/' . $file_system->basename($original_uri);
    $url = $file_url_generator->transformRelative($style->buildUrl($original_uri));
    $variables['#uri'] = $original_uri;
    $this->assertEquals('<img src="' . $url . '" width="50" height="50" alt="" loading="lazy" class="image-style-test-uri" />', $this->getImageTag($variables));
    $this->assertEquals('<img src="' . $url . '" width="50" height="50" alt="" loading="lazy" />', $this->getImageTag($variables));
    $this->assertFileDoesNotExist($generated_uri);
    $this->drupalGet($this->getAbsoluteUrl($url));
    $this->assertSession()->statusCodeEquals(200);
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ class ConvertTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
+2 −2
Original line number Diff line number Diff line
@@ -223,8 +223,8 @@ public function testDefaultImages() {

    $non_image = $this->drupalGetTestFiles('text');
    $this->submitForm(['files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($non_image[0]->uri)], 'Upload');
    $this->assertSession()->pageTextContains('The specified file text-0.txt could not be uploaded.');
    $this->assertSession()->pageTextContains('Only files with the following extensions are allowed: png gif jpg jpeg.');
    $this->assertSession()->statusMessageContains('The specified file text-0.txt could not be uploaded.', 'error');
    $this->assertSession()->statusMessageContains('Only files with the following extensions are allowed: png gif jpg jpeg.', 'error');

    // Confirm the default image is shown on the node form.
    $file = File::load($default_images['field_storage_new']->id());
+5 −5
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * Tests image formatters on node display for public files.
@@ -289,7 +289,7 @@ public function testImageFieldSettings() {

    $file_url_generator = \Drupal::service('file_url_generator');
    $url = $file_url_generator->transformRelative(ImageStyle::load('medium')->buildUrl($file->getFileUri()));
    $this->assertSession()->elementExists('css', 'img[width=40][height=20][class=image-style-medium][src="' . $url . '"]');
    $this->assertSession()->elementExists('css', 'img[width=40][height=20][src="' . $url . '"]');

    // Add alt/title fields to the image and verify that they are displayed.
    $image = [
@@ -319,8 +319,8 @@ public function testImageFieldSettings() {
    $this->drupalGet('node/' . $nid . '/edit');
    $this->submitForm($edit, 'Save');
    $schema = $field->getFieldStorageDefinition()->getSchema();
    $this->assertSession()->pageTextContains("Alternative text cannot be longer than {$schema['columns']['alt']['length']} characters but is currently {$test_size} characters long.");
    $this->assertSession()->pageTextContains("Title cannot be longer than {$schema['columns']['title']['length']} characters but is currently {$test_size} characters long.");
    $this->assertSession()->statusMessageContains("Alternative text cannot be longer than {$schema['columns']['alt']['length']} characters but is currently {$test_size} characters long.", 'error');
    $this->assertSession()->statusMessageContains("Title cannot be longer than {$schema['columns']['title']['length']} characters but is currently {$test_size} characters long.", 'error');

    // Set cardinality to unlimited and add upload a second image.
    // The image widget is extending on the file widget, but the image field
@@ -340,7 +340,7 @@ public function testImageFieldSettings() {
    $this->submitForm($edit, 'Save');
    // Add the required alt text.
    $this->submitForm([$field_name . '[1][alt]' => $alt], 'Save');
    $this->assertSession()->pageTextContains('Article ' . $node->getTitle() . ' has been updated.');
    $this->assertSession()->statusMessageContains('Article ' . $node->getTitle() . ' has been updated.', 'status');

    // Assert ImageWidget::process() calls FieldWidget::process().
    $this->drupalGet('node/' . $node->id() . '/edit');
Loading