diff --git a/tests/bundle/Command/UpdateUserCommandTest.php b/tests/bundle/Command/UpdateUserCommandTest.php new file mode 100644 index 0000000..244852d --- /dev/null +++ b/tests/bundle/Command/UpdateUserCommandTest.php @@ -0,0 +1,87 @@ +setAutoExit(false); + + $command = $application->find('ibexa:user:update-user'); + $this->commandTester = new CommandTester($command); + } + + public function testExecuteWithoutOptionsReturnsFailure(): void + { + $this->commandTester->execute([ + 'user' => 'anonymous', + ]); + + 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' => 'anonymous', + '--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' => 'anonymous', + '--password' => true, + '--email' => 'foo@bar.com', + '--enable' => true, + ], + ); + + self::assertStringContainsString( + 'User was successfully updated.', + $this->commandTester->getDisplay() + ); + + $this->commandTester->assertCommandIsSuccessful(); + } +}