mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-23 21:27:44 +03:00
Created VisitServiceTest
This commit is contained in:
parent
ce4877d4ac
commit
9c6420fe26
1 changed files with 49 additions and 0 deletions
49
module/Core/test/Service/VisitServiceTest.php
Normal file
49
module/Core/test/Service/VisitServiceTest.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
namespace ShlinkioTest\Shlink\Core\Service;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use PHPUnit_Framework_TestCase as TestCase;
|
||||||
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
|
use Shlinkio\Shlink\Core\Repository\VisitRepository;
|
||||||
|
use Shlinkio\Shlink\Core\Service\VisitService;
|
||||||
|
|
||||||
|
class VisitServiceTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var VisitService
|
||||||
|
*/
|
||||||
|
protected $visitService;
|
||||||
|
/**
|
||||||
|
* @var ObjectProphecy
|
||||||
|
*/
|
||||||
|
protected $em;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->em = $this->prophesize(EntityManager::class);
|
||||||
|
$this->visitService = new VisitService($this->em->reveal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function saveVisitsPersistsProvidedVisit()
|
||||||
|
{
|
||||||
|
$visit = new Visit();
|
||||||
|
$this->em->persist($visit)->shouldBeCalledTimes(1);
|
||||||
|
$this->em->flush()->shouldBeCalledTimes(1);
|
||||||
|
$this->visitService->saveVisit($visit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function getUnlocatedVisitsFallbacksToRepository()
|
||||||
|
{
|
||||||
|
$repo = $this->prophesize(VisitRepository::class);
|
||||||
|
$repo->findUnlocatedVisits()->shouldBeCalledTimes(1);
|
||||||
|
$this->em->getRepository(Visit::class)->willReturn($repo->reveal())->shouldBeCalledTimes(1);
|
||||||
|
$this->visitService->getUnlocatedVisits();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue