function ResponsiveImageStyleConfigEntityUnitTest::testHasImageStyleMappings

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

@covers ::addImageStyleMapping @covers ::hasImageStyleMappings

File

core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php, line 127

Class

ResponsiveImageStyleConfigEntityUnitTest
@coversDefaultClass \Drupal\responsive_image\Entity\ResponsiveImageStyle @group block

Namespace

Drupal\Tests\responsive_image\Unit

Code

public function testHasImageStyleMappings() : void {
    $entity = new ResponsiveImageStyle([]);
    $this->assertFalse($entity->hasImageStyleMappings());
    $entity->addImageStyleMapping('test_breakpoint', '1x', [
        'image_mapping_type' => 'image_style',
        'image_mapping' => '',
    ]);
    $this->assertFalse($entity->hasImageStyleMappings());
    $entity->removeImageStyleMappings();
    $entity->addImageStyleMapping('test_breakpoint', '1x', [
        'image_mapping_type' => 'sizes',
        'image_mapping' => [
            'sizes' => '(min-width:700px) 700px, 100vw',
            'sizes_image_styles' => [],
        ],
    ]);
    $this->assertFalse($entity->hasImageStyleMappings());
    $entity->removeImageStyleMappings();
    $entity->addImageStyleMapping('test_breakpoint', '1x', [
        'image_mapping_type' => 'sizes',
        'image_mapping' => [
            'sizes' => '',
            'sizes_image_styles' => [
                'large' => 'large',
            ],
        ],
    ]);
    $this->assertFalse($entity->hasImageStyleMappings());
    $entity->removeImageStyleMappings();
    $entity->addImageStyleMapping('test_breakpoint', '1x', [
        'image_mapping_type' => 'image_style',
        'image_mapping' => 'large',
    ]);
    $this->assertTrue($entity->hasImageStyleMappings());
    $entity->removeImageStyleMappings();
    $entity->addImageStyleMapping('test_breakpoint', '1x', [
        'image_mapping_type' => 'sizes',
        'image_mapping' => [
            'sizes' => '(min-width:700px) 700px, 100vw',
            'sizes_image_styles' => [
                'large' => 'large',
            ],
        ],
    ]);
    $this->assertTrue($entity->hasImageStyleMappings());
}

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