|
1 | 1 | <?php
|
2 | 2 | /**
|
3 | 3 | * @link http://github.com/zendframework/zend-mvc-console for the canonical source repository
|
4 |
| - * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) |
| 4 | + * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (http://www.zend.com) |
5 | 5 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
6 | 6 | */
|
7 | 7 |
|
|
10 | 10 | use Interop\Container\ContainerInterface;
|
11 | 11 | use PHPUnit_Framework_TestCase as TestCase;
|
12 | 12 | use Prophecy\Argument;
|
| 13 | +use ReflectionMethod; |
| 14 | +use Zend\Mvc\Application; |
13 | 15 | use Zend\Mvc\Console\Service\ConsoleViewHelperManagerDelegatorFactory;
|
| 16 | +use Zend\Mvc\MvcEvent; |
| 17 | +use Zend\Router\RouteMatch; |
| 18 | +use Zend\Router\RouteStackInterface; |
14 | 19 | use Zend\View\HelperPluginManager;
|
15 | 20 | use Zend\View\Helper;
|
16 | 21 |
|
@@ -57,4 +62,30 @@ public function testInjectsPluginFactoriesWhenInConsoleEnvironment()
|
57 | 62 | $this->factory->__invoke($this->container, 'ViewHelperManager', $this->callback)
|
58 | 63 | );
|
59 | 64 | }
|
| 65 | + |
| 66 | + public function testCreateUrlHelperFactoryInjectsHelperWithRouterAndRouteMatchWhenPresent() |
| 67 | + { |
| 68 | + $container = $this->prophesize(ContainerInterface::class); |
| 69 | + |
| 70 | + $router = $this->prophesize(RouteStackInterface::class); |
| 71 | + $container->get('HttpRouter')->will([$router, 'reveal']); |
| 72 | + |
| 73 | + $routeMatch = $this->prophesize(RouteMatch::class); |
| 74 | + |
| 75 | + $mvcEvent = $this->prophesize(MvcEvent::class); |
| 76 | + $mvcEvent->getRouteMatch()->will([$routeMatch, 'reveal']); |
| 77 | + |
| 78 | + $application = $this->prophesize(Application::class); |
| 79 | + $application->getMvcEvent()->will([$mvcEvent, 'reveal']); |
| 80 | + $container->get('Application')->will([$application, 'reveal']); |
| 81 | + |
| 82 | + $r = new ReflectionMethod($this->factory, 'createUrlHelperFactory'); |
| 83 | + $r->setAccessible(true); |
| 84 | + $factory = $r->invoke($this->factory, $container->reveal()); |
| 85 | + |
| 86 | + $helper = $factory(); |
| 87 | + |
| 88 | + $this->assertAttributeSame($router->reveal(), 'router', $helper); |
| 89 | + $this->assertAttributeSame($routeMatch->reveal(), 'routeMatch', $helper); |
| 90 | + } |
60 | 91 | }
|
0 commit comments