function ResponsiveImageStyleConfigEntityUnitTest::testSetBreakpointGroup
@covers ::setBreakpointGroup
      
    
@covers ::getBreakpointGroup
      
    
File
- 
              core/modules/ responsive_image/ tests/ src/ Unit/ ResponsiveImageStyleConfigEntityUnitTest.php, line 373 
Class
- ResponsiveImageStyleConfigEntityUnitTest
- @coversDefaultClass \Drupal\responsive_image\Entity\ResponsiveImageStyle[[api-linebreak]] @group block
Namespace
Drupal\Tests\responsive_image\UnitCode
public function testSetBreakpointGroup() : void {
  $entity = new ResponsiveImageStyle([
    'breakpoint_group' => 'test_group',
  ]);
  $entity->addImageStyleMapping('test_breakpoint', '1x', [
    'image_mapping_type' => 'image_style',
    'image_mapping' => 'large',
  ]);
  $entity->addImageStyleMapping('test_breakpoint', '2x', [
    'image_mapping_type' => 'sizes',
    'image_mapping' => [
      'sizes' => '(min-width:700px) 700px, 100vw',
      'sizes_image_styles' => [
        'large' => 'large',
      ],
    ],
  ]);
  $entity->addImageStyleMapping('test_breakpoint2', '1x', [
    'image_mapping_type' => 'image_style',
    'image_mapping' => 'thumbnail',
  ]);
  // Ensure that setting to same group does not remove mappings.
  $entity->setBreakpointGroup('test_group');
  $this->assertTrue($entity->hasImageStyleMappings());
  $this->assertEquals('test_group', $entity->getBreakpointGroup());
  // Ensure that changing the group removes mappings.
  $entity->setBreakpointGroup('test_group2');
  $this->assertEquals('test_group2', $entity->getBreakpointGroup());
  $this->assertFalse($entity->hasImageStyleMappings());
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
