Same name in other branches
  1. 2.x tests/src/Functional/EntityCloneResponsiveImageStyleTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneResponsiveImageStyleTest::testResponsiveImageStyleEntityClone()

Test responsive image style entity clone.

Fichier

tests/src/Functional/EntityCloneResponsiveImageStyleTest.php, line 62

Classe

EntityCloneResponsiveImageStyleTest
Create a responsive image style and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

public function testResponsiveImageStyleEntityClone() {
    $edit = [
        'label' => 'Test responsive image style for clone',
        'id' => 'test_responsive_image_style_for_clone',
        'breakpoint_group' => 'responsive_image',
        'fallback_image_style' => 'large',
    ];
    $this->drupalGet("admin/config/media/responsive-image-style/add");
    $this->submitForm($edit, $this->t('Save'));
    $responsive_image_styles = \Drupal::entityTypeManager()->getStorage('responsive_image_style')
        ->loadByProperties([
        'id' => $edit['id'],
    ]);
    $responsive_image_style = reset($responsive_image_styles);
    $edit = [
        'id' => 'test_responsive_image_style_cloned',
        'label' => 'Test responsive image style cloned',
    ];
    $this->drupalGet('entity_clone/responsive_image_style/' . $responsive_image_style->id());
    $this->submitForm($edit, $this->t('Clone'));
    $responsive_image_styles = \Drupal::entityTypeManager()->getStorage('responsive_image_style')
        ->loadByProperties([
        'id' => $edit['id'],
    ]);
    $responsive_image_style = reset($responsive_image_styles);
    $this->assertInstanceOf(ResponsiveImageStyle::class, $responsive_image_style, 'Test responsive image style cloned found in database.');
}