Same name in other branches
  1. 8.x-1.x tests/src/Functional/EntityCloneResponsiveImageStyleTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneResponsiveImageStyleTest

Create a responsive image style and test a clone.

@group entity_clone

Hierarchy

  • class \Drupal\Tests\entity_clone\Functional\EntityCloneResponsiveImageStyleTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait

Expanded class hierarchy of EntityCloneResponsiveImageStyleTest

Fichier

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

Namespace

Drupal\Tests\entity_clone\Functional
View source
class EntityCloneResponsiveImageStyleTest extends BrowserTestBase {
    use StringTranslationTrait;
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'entity_clone',
        'responsive_image',
    ];
    
    /**
     * Theme to enable by default.
     *
     * @var string
     */
    protected $defaultTheme = 'claro';
    
    /**
     * Permissions to grant admin user.
     *
     * @var array
     */
    protected $permissions = [
        'clone responsive_image_style entity',
        'administer responsive images',
    ];
    
    /**
     * An administrative user with permission to configure image styles settings.
     *
     * @var \Drupal\user\UserInterface
     */
    protected $adminUser;
    
    /**
     * Sets the test up.
     */
    protected function setUp() : void {
        parent::setUp();
        $this->adminUser = $this->drupalCreateUser($this->permissions);
        $this->drupalLogin($this->adminUser);
    }
    
    /**
     * Test responsive image style entity clone.
     */
    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.');
    }

}

Members

Titre Trier par ordre décroissant Modifiers Object type Résumé
EntityCloneResponsiveImageStyleTest::$adminUser protected property An administrative user with permission to configure image styles settings.
EntityCloneResponsiveImageStyleTest::$defaultTheme protected property Theme to enable by default.
EntityCloneResponsiveImageStyleTest::$modules protected static property Modules to enable.
EntityCloneResponsiveImageStyleTest::$permissions protected property Permissions to grant admin user.
EntityCloneResponsiveImageStyleTest::setUp protected function Sets the test up.
EntityCloneResponsiveImageStyleTest::testResponsiveImageStyleEntityClone public function Test responsive image style entity clone.