EntityCloneUserTest.php in Entity Clone 8
File
tests/src/Functional/EntityCloneUserTest.php
View source
<?php
namespace Drupal\Tests\entity_clone\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\Entity\User;
class EntityCloneUserTest extends BrowserTestBase {
public static $modules = [
'entity_clone',
'user',
];
protected $defaultTheme = 'classy';
protected $permissions = [
'clone user entity',
];
protected $adminUser;
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser($this->permissions, 'test_user');
$this
->drupalLogin($this->adminUser);
}
public function testUserEntityClone() {
$this
->drupalPostForm('entity_clone/user/' . $this->adminUser
->id(), [], t('Clone'));
$users = \Drupal::entityTypeManager()
->getStorage('user')
->loadByProperties([
'name' => 'test_user_cloned',
]);
$user = reset($users);
$this
->assertInstanceOf(User::class, $user, 'Test user cloned found in database.');
}
}