/**
  * @test
  */
 public function addRedirectEmitSignalAndFlushesRouterCacheForAffectedUri()
 {
     $this->mockRedirectRepository->expects($this->atLeastOnce())->method('findByTargetUriPathAndHost')->willReturn([]);
     $this->mockRouterCachingService->expects($this->once())->method('flushCachesForUriPath')->with('some/relative/path');
     $this->redirectServiceMock->expects($this->atLeastOnce())->method('emitRedirectCreated');
     $this->redirectStorage->addRedirect('some/relative/path', 'target');
 }
 /**
  * Increment the hit counter for the given redirect.
  *
  * @param RedirectInterface $redirect
  * @return void
  * @api
  */
 public function incrementHitCount(RedirectInterface $redirect)
 {
     try {
         $this->redirectRepository->incrementHitCount($redirect);
     } catch (\Exception $exception) {
         $this->_logger->logException($exception);
     }
 }
예제 #3
0
 /**
  * @test
  * @dataProvider addRedirectDataProvider
  *
  * @param array $existingRedirects
  * @param array $newRedirects
  * @param array $expectedRedirects
  */
 public function addRedirectTests(array $existingRedirects, array $newRedirects, array $expectedRedirects)
 {
     foreach ($existingRedirects as $sourceUriPath => $targetUriPath) {
         $this->redirectService->addRedirect($sourceUriPath, $targetUriPath);
     }
     $this->persistenceManager->persistAll();
     foreach ($newRedirects as $sourceUriPath => $targetUriPath) {
         $this->redirectService->addRedirect($sourceUriPath, $targetUriPath);
     }
     $this->persistenceManager->persistAll();
     $resultingRedirects = [];
     foreach ($this->redirectRepository->findAll() as $redirect) {
         $resultingRedirects[$redirect->getSourceUriPath()] = $redirect->getTargetUriPath();
     }
     $this->assertSame($expectedRedirects, $resultingRedirects);
 }