Added logic for new tracking options

This commit is contained in:
Alejandro Celaya
2021-05-16 09:51:52 +02:00
parent d423d18249
commit f0dc32b6e5
7 changed files with 76 additions and 27 deletions

View File

@@ -57,6 +57,22 @@ class VisitsTrackerTest extends TestCase
$this->eventDispatcher->dispatch(Argument::type(UrlVisited::class))->shouldHaveBeenCalled();
}
/**
* @test
* @dataProvider provideTrackingMethodNames
*/
public function trackingIsSkippedCompletelyWhenDisabledFromOptions(string $method, array $args): void
{
$this->options->disableTracking = true;
$this->visitsTracker->{$method}(...$args);
$this->eventDispatcher->dispatch(Argument::cetera())->shouldNotHaveBeenCalled();
$this->em->transactional(Argument::cetera())->shouldNotHaveBeenCalled();
$this->em->persist(Argument::cetera())->shouldNotHaveBeenCalled();
$this->em->flush()->shouldNotHaveBeenCalled();
}
public function provideTrackingMethodNames(): iterable
{
yield 'track' => ['track', [ShortUrl::createEmpty(), Visitor::emptyInstance()]];