From 828634c200023d3896fed52bdfe15d127bbc6a9b Mon Sep 17 00:00:00 2001 From: konradoboza Date: Wed, 28 Aug 2024 09:13:10 +0200 Subject: [PATCH] added test coverage --- .../bundle/Command/UpdateUserCommandTest.php | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tests/bundle/Command/UpdateUserCommandTest.php diff --git a/tests/bundle/Command/UpdateUserCommandTest.php b/tests/bundle/Command/UpdateUserCommandTest.php new file mode 100644 index 0000000..aa86cee --- /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' => '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' => 'foo@bar.com', + '--enable' => true, + ], + ); + + self::assertStringContainsString( + 'User was successfully updated.', + $this->commandTester->getDisplay() + ); + + $this->commandTester->assertCommandIsSuccessful(); + } +}