Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 16, 2023
1 parent 6b7a69b commit 4bd2c3f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/Commands/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ public function testCreateNotUniqueName(): void
$this->assertNull($user);
}

public function testCreatePasswordNotMatch(): void
{
$user = $this->createUser([
'username' => 'user1',
'email' => '[email protected]',
'password' => 'secret123',
]);

$this->setMockIo([
'password',
'badpassword',
]);

command('shield:user create -n user1 -e [email protected]');

$this->assertStringContainsString(
"The passwords don't match",
$this->io->getFirstOutput()
);

$users = model(UserModel::class);
$user = $users->findByCredentials(['email' => '[email protected]']);
$this->assertNull($user);
}

/**
* Create an active user.
*/
Expand Down Expand Up @@ -321,6 +346,28 @@ public function testDeleteById(): void
$this->assertNull($user);
}

public function testDeleteUserNotExist(): void
{
$this->createUser([
'username' => 'user6',
'email' => '[email protected]',
'password' => 'secret123',
]);

$this->setMockIo(['y']);

command('shield:user delete -n userx');

$this->assertStringContainsString(
"User doesn't exist",
$this->io->getLastOutput()
);

$users = model(UserModel::class);
$user = $users->findByCredentials(['email' => '[email protected]']);
$this->assertNotNull($user);
}

public function testPassword(): void
{
$this->createUser([
Expand Down

0 comments on commit 4bd2c3f

Please sign in to comment.