/** * @test */ public function handleStoresRouterMatchResultsInTheComponentContext() { $mockMatchResults = array('someRouterMatchResults'); $this->mockRouter->expects($this->atLeastOnce())->method('route')->with($this->mockHttpRequest)->will($this->returnValue($mockMatchResults)); $this->mockComponentContext->expects($this->atLeastOnce())->method('setParameter')->with(\TYPO3\Flow\Mvc\Routing\RoutingComponent::class, 'matchResults', $mockMatchResults); $this->routingComponent->handle($this->mockComponentContext); }
/** * @test */ public function routeReturnsCachedMatchResultsIfFoundInCache() { $cachedMatchResults = array('some' => 'cached results'); $mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock(); $mockActionRequest->expects($this->once())->method('getArguments')->will($this->returnValue(array())); $mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock(); $mockHttpRequest->expects($this->once())->method('createActionRequest')->will($this->returnValue($mockActionRequest)); $mockRouterCachingService = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Routing\\RouterCachingService')->getMock(); $mockRouterCachingService->expects($this->once())->method('getCachedMatchResults')->with($mockHttpRequest)->will($this->returnValue($cachedMatchResults)); $this->router->_set('routerCachingService', $mockRouterCachingService); $this->router->expects($this->never())->method('createRoutesFromConfiguration'); $this->assertSame($mockActionRequest, $this->router->route($mockHttpRequest)); }