function ResponsiveImageStyleResourceTestBase::createEntity

Same name in other branches
  1. 9 core/modules/responsive_image/tests/src/Functional/Rest/ResponsiveImageStyleResourceTestBase.php \Drupal\Tests\responsive_image\Functional\Rest\ResponsiveImageStyleResourceTestBase::createEntity()
  2. 8.9.x core/modules/responsive_image/tests/src/Functional/Rest/ResponsiveImageStyleResourceTestBase.php \Drupal\Tests\responsive_image\Functional\Rest\ResponsiveImageStyleResourceTestBase::createEntity()
  3. 10 core/modules/responsive_image/tests/src/Functional/Rest/ResponsiveImageStyleResourceTestBase.php \Drupal\Tests\responsive_image\Functional\Rest\ResponsiveImageStyleResourceTestBase::createEntity()

Overrides EntityResourceTestBase::createEntity

File

core/modules/responsive_image/tests/src/Functional/Rest/ResponsiveImageStyleResourceTestBase.php, line 49

Class

ResponsiveImageStyleResourceTestBase
ResourceTestBase for ResponsiveImageStyle entity.

Namespace

Drupal\Tests\responsive_image\Functional\Rest

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;
}

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