function ViewsIntegrationTest::testViewsAddResponsiveImageField

Same name and namespace in other branches
  1. 9 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::testViewsAddResponsiveImageField()
  2. 10 core/modules/responsive_image/tests/src/Functional/ViewsIntegrationTest.php \Drupal\Tests\responsive_image\Functional\ViewsIntegrationTest::testViewsAddResponsiveImageField()
  3. 11.x 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 96

Class

ViewsIntegrationTest
Tests the integration of responsive image with Views.

Namespace

Drupal\Tests\responsive_image\Functional

Code

public function testViewsAddResponsiveImageField() {
    // Add the image field to the View.
    $this->drupalGet('admin/structure/views/nojs/add-handler/entity_test_row/default/field');
    $this->drupalPostForm('admin/structure/views/nojs/add-handler/entity_test_row/default/field', [
        'name[entity_test__bar.bar]' => TRUE,
    ], 'Add and configure field');
    // Set the formatter to 'Responsive image'.
    $this->drupalPostForm(NULL, [
        'options[type]' => 'responsive_image',
    ], 'Apply');
    $this->assertSession()
        ->responseContains('Responsive image style field is required.');
    $this->drupalPostForm(NULL, [
        '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.