diff --git a/tests/Core/Command/CreateUserTest.php b/tests/Core/Command/CreateUserTest.php new file mode 100644 index 0000000..306f120 --- /dev/null +++ b/tests/Core/Command/CreateUserTest.php @@ -0,0 +1,64 @@ +query = self::$container->get(UserRepositoryQuery::class); + } + + public function testCommandExecute(): void + { + $kernel = static::createKernel(); + $application = new Application($kernel); + $command = $application->find('murph:user:create'); + $commandTester = new CommandTester($command); + + $commandTester->setInputs([ + 'admin@localhost', + 'admin_password', + 'y', + 'n', + ]); + $commandTester->execute(['command' => $command->getName()]); + $output = $commandTester->getDisplay(); + $this->assertStringContainsString('User created!', $output); + + $commandTester->setInputs([ + 'writer@localhost', + 'writer_password', + 'n', + 'y', + ]); + $commandTester->execute(['command' => $command->getName()]); + $output = $commandTester->getDisplay(); + $this->assertStringContainsString('User created!', $output); + } + + public function testCreatedUsers(): void + { + $users = $this->query->create()->find(); + $this->assertEquals(2, count($users)); + + $this->assertEquals('admin@localhost', $users[0]->getEmail()); + $this->assertEquals('admin@localhost', $users[0]->getUsername()); + $this->assertEquals('writer@localhost', $users[1]->getEmail()); + $this->assertEquals('writer@localhost', $users[1]->getUsername()); + + $this->assertEquals(true, $users[0]->getIsAdmin()); + $this->assertEquals(false, $users[0]->getIsWriter()); + $this->assertEquals(false, $users[1]->getIsAdmin()); + $this->assertEquals(true, $users[1]->getIsWriter()); + } +}