You are here

protected function ResponsiveImageFieldDisplayTest::addTestImageStyleMappings in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php \Drupal\responsive_image\Tests\ResponsiveImageFieldDisplayTest::addTestImageStyleMappings()

Add image style mappings to the responsive image style entity.

Parameters

bool $empty_styles: If true, the image style mappings will get empty image styles.

5 calls to ResponsiveImageFieldDisplayTest::addTestImageStyleMappings()
ResponsiveImageFieldDisplayTest::testResponsiveImageFieldFormattersEmptyStyle in core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
Test responsive image formatters when image style is empty.
ResponsiveImageFieldDisplayTest::testResponsiveImageFieldFormattersLinkToFile in core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
Tests responsive image formatters on node display linked to the file.
ResponsiveImageFieldDisplayTest::testResponsiveImageFieldFormattersLinkToNode in core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
Tests responsive image formatters on node display linked to the node.
ResponsiveImageFieldDisplayTest::testResponsiveImageFieldFormattersPrivate in core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
Tests responsive image formatters on node display for private files.
ResponsiveImageFieldDisplayTest::testResponsiveImageFieldFormattersPublic in core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
Tests responsive image formatters on node display for public files.

File

core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php, line 103
Contains \Drupal\responsive_image\Tests\ResponsiveImageFieldDisplayTest.

Class

ResponsiveImageFieldDisplayTest
Tests responsive image display formatter.

Namespace

Drupal\responsive_image\Tests

Code

protected function addTestImageStyleMappings($empty_styles = FALSE) {
  if ($empty_styles) {
    $this->responsiveImgStyle
      ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array(
      'image_mapping_type' => 'image_style',
      'image_mapping' => '',
    ))
      ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', array(
      'image_mapping_type' => 'sizes',
      'image_mapping' => array(
        'sizes' => '(min-width: 700px) 700px, 100vw',
        'sizes_image_styles' => array(),
      ),
    ))
      ->addImageStyleMapping('responsive_image_test_module.wide', '1x', array(
      'image_mapping_type' => 'image_style',
      'image_mapping' => '',
    ))
      ->save();
  }
  else {
    $this->responsiveImgStyle
      ->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array(
      'image_mapping_type' => 'image_style',
      'image_mapping' => RESPONSIVE_IMAGE_EMPTY_IMAGE,
    ))
      ->addImageStyleMapping('responsive_image_test_module.mobile', '1.5x', array(
      'image_mapping_type' => 'image_style',
      'image_mapping' => 'thumbnail',
    ))
      ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', array(
      'image_mapping_type' => 'sizes',
      'image_mapping' => array(
        'sizes' => '(min-width: 700px) 700px, 100vw',
        'sizes_image_styles' => array(
          'large',
          'medium',
        ),
      ),
    ))
      ->addImageStyleMapping('responsive_image_test_module.wide', '1x', array(
      'image_mapping_type' => 'image_style',
      'image_mapping' => 'large',
    ))
      ->addImageStyleMapping('responsive_image_test_module.wide', '3x', array(
      'image_mapping_type' => 'image_style',
      'image_mapping' => RESPONSIVE_IMAGE_ORIGINAL_IMAGE,
    ))
      ->save();
  }
}