dbUpdater = $this->prophesize(DbUpdaterInterface::class); $command = new UpdateDbCommand($this->dbUpdater->reveal(), Translator::factory([])); $app = new Application(); $app->add($command); $this->commandTester = new CommandTester($command); } /** * @test */ public function successMessageIsPrintedIfEverythingWorks() { $download = $this->dbUpdater->downloadFreshCopy(Argument::type('callable'))->will(function () { }); $this->commandTester->execute([]); $output = $this->commandTester->getDisplay(); $this->assertContains('GeoLite2 database properly updated', $output); $download->shouldHaveBeenCalledOnce(); } /** * @test */ public function errorMessageIsPrintedIfAnExceptionIsThrown() { $download = $this->dbUpdater->downloadFreshCopy(Argument::type('callable'))->willThrow(RuntimeException::class); $this->commandTester->execute([]); $output = $this->commandTester->getDisplay(); $this->assertContains('An error occurred while updating GeoLite2 database', $output); $download->shouldHaveBeenCalledOnce(); } }