Files
Phraseanet/tests/Alchemy/Tests/Phrasea/Application/RouteLoaderTest.php
Thibaud Fabre 450adb0847 Application bootstrap refactor
- Extract environment properties in Environment class
- Replaces initialisation closure by ApplicationLoader class
- Removes undesirable error handling/PHP settings modifications
2016-01-22 17:12:21 +01:00

49 lines
1.5 KiB
PHP

<?php
namespace Alchemy\Tests\Phrasea\Application;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application\RouteLoader;
use Prophecy\Argument;
use Silex\ControllerCollection;
use Silex\ControllerProviderInterface;
use Silex\Route;
class RouteLoaderTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \InvalidArgumentException
*/
public function testRegisterProviderWithInvalidClassFails()
{
$routeLoader = new RouteLoader();
$routeLoader->registerProvider('test_invalid_class', '\Alchemy\Tests\Phrasea\Application\UndefinedClass');
}
public function testRegisteredProvidersAreMountedInApplication()
{
$application = $this->prophesize(Application::class);
$application->offsetGet(Argument::any())
->shouldBeCalled();
$application->mount(Argument::any(), Argument::type(ControllerProviderInterface::class))
->shouldBeCalled();
$application->mount(Argument::exact('mount_prefix'), Argument::type(MockControllerProvider::class))
->shouldBeCalled();
$routeLoader = new RouteLoader();
$routeLoader->registerProvider('mount_prefix', MockControllerProvider::class);
$routeLoader->bindRoutes($application->reveal());
}
}
class MockControllerProvider implements ControllerProviderInterface
{
public function connect(\Silex\Application $app)
{
return new ControllerCollection(new Route('/'));
}
}