mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-22 08:56:42 -06:00
Migrated GetOrphanVisitsCommandTest to use PHPUnit mocks
This commit is contained in:
parent
82e04800aa
commit
e2986a7b4c
@ -5,9 +5,8 @@ declare(strict_types=1);
|
||||
namespace ShlinkioTest\Shlink\CLI\Command\Visit;
|
||||
|
||||
use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\CLI\Command\Visit\GetOrphanVisitsCommand;
|
||||
use Shlinkio\Shlink\Common\Paginator\Paginator;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
|
||||
@ -23,12 +22,12 @@ class GetOrphanVisitsCommandTest extends TestCase
|
||||
use CliTestUtilsTrait;
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private ObjectProphecy $visitsHelper;
|
||||
private MockObject $visitsHelper;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->visitsHelper = $this->prophesize(VisitsStatsHelperInterface::class);
|
||||
$this->commandTester = $this->testerForCommand(new GetOrphanVisitsCommand($this->visitsHelper->reveal()));
|
||||
$this->visitsHelper = $this->createMock(VisitsStatsHelperInterface::class);
|
||||
$this->commandTester = $this->testerForCommand(new GetOrphanVisitsCommand($this->visitsHelper));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@ -37,7 +36,7 @@ class GetOrphanVisitsCommandTest extends TestCase
|
||||
$visit = Visit::forBasePath(new Visitor('bar', 'foo', '', ''))->locate(
|
||||
VisitLocation::fromGeolocation(new Location('', 'Spain', '', 'Madrid', 0, 0, '')),
|
||||
);
|
||||
$getVisits = $this->visitsHelper->orphanVisits(Argument::any())->willReturn(
|
||||
$this->visitsHelper->expects($this->once())->method('orphanVisits')->withAnyParameters()->willReturn(
|
||||
new Paginator(new ArrayAdapter([$visit])),
|
||||
);
|
||||
|
||||
@ -55,6 +54,5 @@ class GetOrphanVisitsCommandTest extends TestCase
|
||||
OUTPUT,
|
||||
$output,
|
||||
);
|
||||
$getVisits->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user