function ViewsIntegrationTest::testViewsAddResponsiveImageField

Same name in other branches
  1. 9 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::testViewsAddResponsiveImageField()
  2. 8.9.x core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::testViewsAddResponsiveImageField()
  3. 10 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::testViewsAddResponsiveImageField()

Tests integration with Views.

File

core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php, line 100

Class

ViewsIntegrationTest
Tests the integration of responsive image with Views.

Namespace

Drupal\Tests\responsive_image\Functional

Code

public function testViewsAddResponsiveImageField() : void {
    // Add the image field to the View.
    $this->drupalGet('admin/structure/views/nojs/add-handler/entity_test_row/default/field');
    $this->drupalGet('admin/structure/views/nojs/add-handler/entity_test_row/default/field');
    $this->submitForm([
        'name[entity_test__bar.bar]' => TRUE,
    ], 'Add and configure field');
    // Set the formatter to 'Responsive image'.
    $this->submitForm([
        'options[type]' => 'responsive_image',
    ], 'Apply');
    $this->assertSession()
        ->responseContains('Responsive image style field is required.');
    $this->submitForm([
        'options[settings][responsive_image_style]' => self::RESPONSIVE_IMAGE_STYLE_ID,
    ], 'Apply');
    $this->drupalGet('admin/structure/views/nojs/handler/entity_test_row/default/field/bar');
    // Make sure the selected value is set.
    $this->assertSession()
        ->fieldValueEquals('options[settings][responsive_image_style]', self::RESPONSIVE_IMAGE_STYLE_ID);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.