apiKeyService = $this->prophesize(ApiKeyService::class); $command = new ListKeysCommand($this->apiKeyService->reveal(), Translator::factory([])); $app = new Application(); $app->add($command); $this->commandTester = new CommandTester($command); } /** * @test */ public function everythingIsListedIfEnabledOnlyIsNotProvided() { $this->apiKeyService->listKeys(false)->willReturn([ new ApiKey(), new ApiKey(), new ApiKey(), ])->shouldBeCalledOnce(); $this->commandTester->execute([ 'command' => ListKeysCommand::NAME, ]); $output = $this->commandTester->getDisplay(); $this->assertContains('Key', $output); $this->assertContains('Is enabled', $output); $this->assertContains(' +++ ', $output); $this->assertNotContains(' --- ', $output); $this->assertContains('Expiration date', $output); } /** * @test */ public function onlyEnabledKeysAreListedIfEnabledOnlyIsProvided() { $this->apiKeyService->listKeys(true)->willReturn([ (new ApiKey())->disable(), new ApiKey(), ])->shouldBeCalledOnce(); $this->commandTester->execute([ 'command' => ListKeysCommand::NAME, '--enabledOnly' => true, ]); $output = $this->commandTester->getDisplay(); $this->assertContains('Key', $output); $this->assertNotContains('Is enabled', $output); $this->assertNotContains(' +++ ', $output); $this->assertNotContains(' --- ', $output); $this->assertContains('Expiration date', $output); } }