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

Create a view and test a clone.

@group entity_clone

Hierarchy

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

Expanded class hierarchy of EntityCloneViewTest

File

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

Namespace

Drupal\Tests\entity_clone\Functional
View source
class EntityCloneViewTest extends BrowserTestBase {
    use StringTranslationTrait;
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'entity_clone',
        'views',
        'views_ui',
    ];
    
    /**
     * Theme to enable by default.
     *
     * @var string
     */
    protected $defaultTheme = 'claro';
    
    /**
     * Permissions to grant admin user.
     *
     * @var array
     */
    protected $permissions = [
        'clone view entity',
        'administer views',
    ];
    
    /**
     * An administrative user with permission to configure views 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 view entity clone.
     */
    public function testViewEntityClone() {
        $edit = [
            'id' => 'test_view_cloned',
            'label' => 'Test view cloned',
        ];
        $this->drupalGet('entity_clone/view/who_s_new');
        $this->submitForm($edit, $this->t('Clone'));
        $views = \Drupal::entityTypeManager()->getStorage('view')
            ->loadByProperties([
            'id' => $edit['id'],
        ]);
        $view = reset($views);
        $this->assertInstanceOf(View::class, $view, 'Test default view cloned found in database.');
    }

}

Members

Title Sort descending Modifiers Object type Summary
EntityCloneViewTest::$adminUser protected property An administrative user with permission to configure views settings.
EntityCloneViewTest::$defaultTheme protected property Theme to enable by default.
EntityCloneViewTest::$modules protected static property Modules to enable.
EntityCloneViewTest::$permissions protected property Permissions to grant admin user.
EntityCloneViewTest::setUp protected function Sets the test up.
EntityCloneViewTest::testViewEntityClone public function Test view entity clone.