/** * Tests the Route process manager functionality. */ public function testRouteProcessorManager() { $route = new Route(''); $parameters = array('test' => 'test'); $processors = array(10 => $this->getMockProcessor($route, $parameters), 5 => $this->getMockProcessor($route, $parameters), 0 => $this->getMockProcessor($route, $parameters)); // Add the processors in reverse order. foreach ($processors as $priority => $processor) { $this->processorManager->addOutbound($processor, $priority); } $this->processorManager->processOutbound($route, $parameters); }
/** * Tests the Route process manager functionality. */ public function testRouteProcessorManager() { $route = new Route(''); $parameters = array('test' => 'test'); $route_name = 'test_name'; $processors = array(10 => $this->getMockProcessor($route_name, $route, $parameters), 5 => $this->getMockProcessor($route_name, $route, $parameters), 0 => $this->getMockProcessor($route_name, $route, $parameters)); // Add the processors in reverse order. foreach ($processors as $priority => $processor) { $this->processorManager->addOutbound($processor, $priority); } $cacheable_metadata = new CacheableMetadata(); $this->processorManager->processOutbound($route_name, $route, $parameters, $cacheable_metadata); // Default cacheability is: permanently cacheable, no cache tags/contexts. $this->assertEquals((new CacheableMetadata())->setCacheMaxAge(Cache::PERMANENT), $cacheable_metadata); }
/** * Test that the 'scheme' route requirement is respected during url generation. */ public function testUrlGenerationWithHttpsRequirement() { $url = $this->generator->generate('test_4', array(), TRUE); $this->assertEquals('https://localhost/test/four', $url); $this->routeProcessorManager->expects($this->exactly(1))->method('processOutbound')->with($this->anything()); $options = array('absolute' => TRUE, 'https' => TRUE); $url = $this->generator->generateFromRoute('test_1', array(), $options); $this->assertEquals('https://localhost/hello/world', $url); }
/** * Test that the 'scheme' route requirement is respected during url generation. */ public function testUrlGenerationWithHttpsRequirement() { $url = $this->generator->generate('test_4', array(), TRUE); $this->assertEquals('https://localhost/test/four', $url); // No cacheability to test; UrlGenerator::generate() doesn't support // collecting cacheability metadata. $this->routeProcessorManager->expects($this->exactly(2))->method('processOutbound')->with($this->anything()); $options = array('absolute' => TRUE, 'https' => TRUE); $this->assertGenerateFromRoute('test_1', [], $options, 'https://localhost/hello/world', (new CacheableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site'])); }
/** * Test that the 'scheme' route requirement is respected during url generation. */ public function testUrlGenerationWithHttpsRequirement() { $url = $this->generator->generate('test_4', array(), TRUE); $this->assertEquals('https://localhost/test/four', $url); $this->routeProcessorManager->expects($this->exactly(2))->method('processOutbound')->with($this->anything()); $options = array('absolute' => TRUE, 'https' => TRUE); // Mixed-mode sessions are not enabled, so the https option is ignored. $url = $this->generator->generateFromRoute('test_1', array(), $options); $this->assertEquals('http://localhost/hello/world', $url); // Mixed-mode sessions are enabled, so the https option is obeyed. $url = $this->generatorMixedMode->generateFromRoute('test_1', array(), $options); $this->assertEquals('https://localhost/hello/world', $url); }