visitsHelper = $this->createMock(VisitsStatsHelperInterface::class); $this->commandTester = CliTestUtils::testerForCommand(new GetOrphanVisitsCommand($this->visitsHelper)); } #[Test] #[TestWith([[], false])] #[TestWith([['--type' => OrphanVisitType::BASE_URL->value], true])] public function outputIsProperlyGenerated(array $args, bool $includesType): void { $visit = Visit::forBasePath(Visitor::fromParams('bar', 'foo', ''))->locate( VisitLocation::fromLocation(new Location('', 'Spain', '', 'Madrid', 0, 0, '')), ); $this->visitsHelper ->expects($this->once()) ->method('orphanVisits') ->with($this->callback( static fn (OrphanVisitsParams $param) => ( ($includesType && $param->type !== null) || (!$includesType && $param->type === null) ), )) ->willReturn(new Paginator(new ArrayAdapter([$visit]))); $this->commandTester->execute($args); $output = $this->commandTester->getDisplay(); $type = OrphanVisitType::BASE_URL->value; self::assertEquals( <<date->toAtomString()} | | bar | foo | Spain | | Madrid | | Unknown | {$type} | +---------------------------+---------------+------------+--- Page 1 of 1 ---+--------+--------+-------------+--------------+----------+ OUTPUT, $output, ); } }