diff --git a/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php b/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php index c57259783..e6ec58df8 100644 --- a/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php +++ b/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php @@ -15,7 +15,30 @@ trait RewrittenUrlTestTrait public function setUp() { - new URL(null); + $stubRouterAdmin = $this->getMockBuilder('\Symfony\Component\Routing\Router') + ->disableOriginalConstructor() + ->setMethods(array('getContext')) + ->getMock(); + + $stubRequestContext = $this->getMockBuilder('\Symfony\Component\Routing\RequestContext') + ->disableOriginalConstructor() + ->setMethods(array('getHost')) + ->getMock(); + + $stubRequestContext->expects($this->any()) + ->method('getHost') + ->will($this->returnValue('localhost')); + + $stubRouterAdmin->expects($this->any()) + ->method('getContext') + ->will($this->returnValue( + $stubRequestContext + )); + + $container = $this->getContainer(); + $container->set('router.admin', $stubRouterAdmin); + + new URL($container); } /** diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 228e5a3ed..85f5289cd 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -51,17 +51,12 @@ class URL self::$instance = $this; if ($container !== null) - $this->requestContext = $this->getContext($container); + $this->requestContext = $container->get('router.admin')->getContext(); $this->retriever = new RewritingRetriever(); $this->resolver = new RewritingResolver(); } - public function getContext($container) - { - return $container->get('router.admin')->getContext(); - } - /** * Return this class instance, only once instanciated. *