EntityCloneViewTest.php in Entity Clone 8
File
tests/src/Functional/EntityCloneViewTest.php
View source
<?php
namespace Drupal\Tests\entity_clone\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\views\Entity\View;
class EntityCloneViewTest extends BrowserTestBase {
public static $modules = [
'entity_clone',
'views',
];
protected $defaultTheme = 'classy';
protected $permissions = [
'clone view entity',
];
protected $adminUser;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser($this->permissions);
$this
->drupalLogin($this->adminUser);
}
public function testViewEntityClone() {
$edit = [
'id' => 'test_view_cloned',
'label' => 'Test view cloned',
];
$this
->drupalPostForm('entity_clone/view/who_s_new', $edit, 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.');
}
}