From 4146835f6f24d39bf670eb1cec1aef8933ee44e5 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 24 May 2022 17:59:06 +0200 Subject: [PATCH] Created GetOrhanVisitsCommand test --- .../Visit/GetOrphanVisitsCommandTest.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 module/CLI/test/Command/Visit/GetOrphanVisitsCommandTest.php diff --git a/module/CLI/test/Command/Visit/GetOrphanVisitsCommandTest.php b/module/CLI/test/Command/Visit/GetOrphanVisitsCommandTest.php new file mode 100644 index 00000000..c8c10aad --- /dev/null +++ b/module/CLI/test/Command/Visit/GetOrphanVisitsCommandTest.php @@ -0,0 +1,60 @@ +visitsHelper = $this->prophesize(VisitsStatsHelperInterface::class); + $this->commandTester = $this->testerForCommand(new GetOrphanVisitsCommand($this->visitsHelper->reveal())); + } + + /** @test */ + public function outputIsProperlyGenerated(): void + { + $visit = Visit::forBasePath(new Visitor('bar', 'foo', '', ''))->locate( + VisitLocation::fromGeolocation(new Location('', 'Spain', '', 'Madrid', 0, 0, '')), + ); + $getVisits = $this->visitsHelper->orphanVisits(Argument::any())->willReturn( + new Paginator(new ArrayAdapter([$visit])), + ); + + $this->commandTester->execute([]); + $output = $this->commandTester->getDisplay(); + + self::assertEquals( + <<getDate()->toAtomString()} | bar | Spain | Madrid | base_url | + +---------+---------------------------+------------+---------+--------+----------+ + + OUTPUT, + $output, + ); + $getVisits->shouldHaveBeenCalledOnce(); + } +}