Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Add RouteConfigFactory factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Xerkus committed Mar 29, 2018
1 parent f889b95 commit 08f6307
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Zend\Router;

use Zend\Router\Container\RouteConfigFactoryFactory;
use Zend\Router\Container\RoutePluginManagerFactory;

/**
Expand Down Expand Up @@ -46,6 +47,7 @@ public function getDependencyConfig()
'RoutePluginManager' => RoutePluginManager::class,
],
'factories' => [
RouteConfigFactory::class => RouteConfigFactoryFactory::class,
RoutePluginManager::class => RoutePluginManagerFactory::class,
],
];
Expand Down
22 changes: 22 additions & 0 deletions src/Container/RouteConfigFactoryFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @see https://github.com/zendframework/zend-router for the canonical source repository
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-router/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace Zend\Router\Container;

use Psr\Container\ContainerInterface;
use Zend\Router\RouteConfigFactory;
use Zend\Router\RoutePluginManager;

class RouteConfigFactoryFactory
{
public function __invoke(ContainerInterface $container) : RouteConfigFactory
{
return new RouteConfigFactory($container->get(RoutePluginManager::class));
}
}
34 changes: 34 additions & 0 deletions test/Container/RouteConfigFactoryFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* @see https://github.com/zendframework/zend-router for the canonical source repository
* @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-router/blob/master/LICENSE.md New BSD License
*/

declare(strict_types=1);

namespace ZendTest\Router\Container;

use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Zend\Router\Container\RouteConfigFactoryFactory;
use Zend\Router\RouteConfigFactory;
use Zend\Router\RoutePluginManager;
use Zend\ServiceManager\ServiceManager;

/**
* @covers \Zend\Router\Container\RouteConfigFactoryFactory
*/
class RouteConfigFactoryFactoryTest extends TestCase
{
public function testCreates()
{
$container = $this->prophesize(ContainerInterface::class);
$container->get(RoutePluginManager::class)
->willReturn(new RoutePluginManager(new ServiceManager()))
->shouldBeCalled();
$factory = new RouteConfigFactoryFactory();
$service = $factory->__invoke($container->reveal());
$this->assertInstanceOf(RouteConfigFactory::class, $service);
}
}

0 comments on commit 08f6307

Please sign in to comment.