forked from CakeDC/users
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsersDeactivateUserCommandTest.php
More file actions
62 lines (56 loc) · 1.97 KB
/
Copy pathUsersDeactivateUserCommandTest.php
File metadata and controls
62 lines (56 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
namespace CakeDC\Users\Test\TestCase\Command;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
/**
* CakeDC\Users\Command\UsersDeactivateUserCommand Test Case
*
* @uses \CakeDC\Users\Command\UsersDeactivateUserCommand
*/
class UsersDeactivateUserCommandTest extends TestCase
{
use ConsoleIntegrationTestTrait;
/**
* @inheritDoc
*/
protected array $fixtures = [
'plugin.CakeDC/Users.Users',
'plugin.CakeDC/Users.SocialAccounts',
];
/**
* Test execute method
*
* @return void
* @uses \CakeDC\Users\Command\UsersChangeRoleCommand::execute()
*/
public function testExecute(): void
{
$UsersTable = TableRegistry::getTableLocator()->get('CakeDC/Users.Users');
$userIdTarget = '00000000-0000-0000-0000-000000000002';
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'active' => 1]));
$this->exec('cake_d_c/users.users deactivate_user user-2');
$this->assertExitSuccess();
$this->assertOutputRegExp('/^User was de-activated: user-2$/');
//Target must have changed
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'active' => 0]));
}
/**
* Test execute method
*
* @return void
* @uses \CakeDC\Users\Command\UsersChangeRoleCommand::execute()
*/
public function testExecuteNoUsername(): void
{
$UsersTable = TableRegistry::getTableLocator()->get('CakeDC/Users.Users');
$userIdTarget = '00000000-0000-0000-0000-000000000002';
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'active' => 1]));
$this->exec('cake_d_c/users.users deactivate_user');
$this->assertExitError();
$this->assertErrorContains('Please enter a username.');
//Should not change
$this->assertTrue($UsersTable->exists(['id' => $userIdTarget, 'active' => 1]));
}
}