|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Zend Framework (http://framework.zend.com/) |
| 4 | + * |
| 5 | + * @link http://github.com/zendframework/zend-mvc for the canonical source repository |
| 6 | + * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com) |
| 7 | + * @license http://framework.zend.com/license/new-bsd New BSD License |
| 8 | + */ |
| 9 | + |
| 10 | +namespace ZendTest\Mvc\Router\Console; |
| 11 | + |
| 12 | +use PHPUnit_Framework_TestCase as TestCase; |
| 13 | +use ReflectionClass; |
| 14 | +use Zend\Mvc\Router\Console\Catchall; |
| 15 | +use Zend\Mvc\Router\Console\Simple; |
| 16 | +use Zend\Mvc\Router\Console\SimpleRouteStack; |
| 17 | +use Zend\ServiceManager\ServiceManager; |
| 18 | + |
| 19 | +class SimpleRouteStackTest extends TestCase |
| 20 | +{ |
| 21 | + public function routeTypeProvider() |
| 22 | + { |
| 23 | + $catchallOpts = ['defaults' => []]; |
| 24 | + $simpleOpts = ['route' => 'test']; |
| 25 | + |
| 26 | + $data = [ |
| 27 | + 'catchall' => ['catchall', $catchallOpts, Catchall::class], |
| 28 | + 'catchAll' => ['catchAll', $catchallOpts, Catchall::class], |
| 29 | + 'Catchall' => ['Catchall', $catchallOpts, Catchall::class], |
| 30 | + 'CatchAll' => ['CatchAll', $catchallOpts, Catchall::class], |
| 31 | + 'simple' => ['simple', $simpleOpts, Simple::class], |
| 32 | + 'Simple' => ['Simple', $simpleOpts, Simple::class], |
| 33 | + |
| 34 | + Catchall::class => [Catchall::class, $catchallOpts, Catchall::class], |
| 35 | + Simple::class => [Simple::class, $simpleOpts, Simple::class], |
| 36 | + ]; |
| 37 | + |
| 38 | + // Two additional cases under zend-servicemanager v2: |
| 39 | + $r = new ReflectionClass(ServiceManager::class); |
| 40 | + if (! $r->hasMethod('configure')) { |
| 41 | + $data['zendmvcrouterconsolecatchall'] = ['zendmvcrouterconsolecatchall', $catchallOpts, Catchall::class]; |
| 42 | + $data['zendmvcrouterconsolesimple'] = ['zendmvcrouterconsolesimple', $simpleOpts, Simple::class]; |
| 43 | + } |
| 44 | + |
| 45 | + return $data; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @dataProvider routeTypeProvider |
| 50 | + */ |
| 51 | + public function testExpectedAliasesAndFactoriesResolve($serviceName, array $options, $expected) |
| 52 | + { |
| 53 | + $router = new SimpleRouteStack(); |
| 54 | + $routes = $router->getRoutePluginManager(); |
| 55 | + $this->assertInstanceOf($expected, $routes->get($serviceName, $options)); |
| 56 | + } |
| 57 | +} |
0 commit comments