You are here

protected function ResponsiveImageStyleTest::createEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResponsiveImageStyleTest.php \Drupal\Tests\jsonapi\Functional\ResponsiveImageStyleTest::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides ResourceTestBase::createEntity

File

core/modules/jsonapi/tests/src/Functional/ResponsiveImageStyleTest.php, line 52

Class

ResponsiveImageStyleTest
JSON:API integration test for the "ResponsiveImageStyle" config entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function createEntity() {

  // Create a "Camelids" responsive image style.
  $camelids = ResponsiveImageStyle::create([
    'id' => 'camelids',
    'label' => 'Camelids',
  ]);
  $camelids
    ->setBreakpointGroup('test_group');
  $camelids
    ->setFallbackImageStyle('fallback');
  $camelids
    ->addImageStyleMapping('test_breakpoint', '1x', [
    'image_mapping_type' => 'image_style',
    'image_mapping' => 'small',
  ]);
  $camelids
    ->addImageStyleMapping('test_breakpoint', '2x', [
    'image_mapping_type' => 'sizes',
    'image_mapping' => [
      'sizes' => '(min-width:700px) 700px, 100vw',
      'sizes_image_styles' => [
        'medium' => 'medium',
        'large' => 'large',
      ],
    ],
  ]);
  $camelids
    ->save();
  return $camelids;
}