-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59503aa
commit 828634c
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Bundle\User\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
final class UpdateUserCommandTest extends KernelTestCase | ||
{ | ||
private readonly CommandTester $commandTester; | ||
|
||
protected function setUp(): void | ||
{ | ||
self::bootKernel(); | ||
|
||
$application = new Application(self::$kernel); | ||
$application->setAutoExit(false); | ||
|
||
$command = $application->find('ibexa:user:update-user'); | ||
$this->commandTester = new CommandTester($command); | ||
} | ||
|
||
public function testExecuteWithoutOptionsReturnsFailure(): void | ||
{ | ||
$this->commandTester->execute([ | ||
'user' => 'admin', | ||
]); | ||
|
||
self::assertStringContainsString( | ||
'No new user data specified, exiting.', | ||
$this->commandTester->getDisplay() | ||
); | ||
|
||
self::assertSame( | ||
Command::FAILURE, | ||
$this->commandTester->getStatusCode() | ||
); | ||
} | ||
|
||
public function testExecuteWithEnableAndDisableOptionsReturnsFailure(): void | ||
{ | ||
$this->commandTester->execute( | ||
[ | ||
'user' => 'admin', | ||
'--enable' => true, | ||
'--disable' => true, | ||
], | ||
); | ||
|
||
self::assertStringContainsString( | ||
'--enable and --disable options cannot be used simultaneously.', | ||
$this->commandTester->getDisplay() | ||
); | ||
|
||
self::assertSame( | ||
Command::FAILURE, | ||
$this->commandTester->getStatusCode() | ||
); | ||
} | ||
|
||
public function testExecuteReturnsSuccess(): void | ||
{ | ||
$this->commandTester->execute( | ||
[ | ||
'user' => 'admin', | ||
'--password' => true, | ||
'--email' => '[email protected]', | ||
'--enable' => true, | ||
], | ||
); | ||
|
||
self::assertStringContainsString( | ||
'User was successfully updated.', | ||
$this->commandTester->getDisplay() | ||
); | ||
|
||
$this->commandTester->assertCommandIsSuccessful(); | ||
} | ||
} |