mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Application bootstrap refactor
- Extract environment properties in Environment class - Replaces initialisation closure by ApplicationLoader class - Removes undesirable error handling/PHP settings modifications
This commit is contained in:
48
tests/Alchemy/Tests/Phrasea/Application/RouteLoaderTest.php
Normal file
48
tests/Alchemy/Tests/Phrasea/Application/RouteLoaderTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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('/'));
|
||||
}
|
||||
}
|
@@ -37,9 +37,11 @@ class DebuggerSubscriberTest extends \PhraseanetTestCase
|
||||
|
||||
$app['conf']->set(['debugger', 'allowed-ips'], $authorized);
|
||||
$app['dispatcher']->addSubscriber(new DebuggerSubscriber($app));
|
||||
|
||||
$app->get('/', function () {
|
||||
return 'success';
|
||||
});
|
||||
|
||||
$app->boot();
|
||||
|
||||
if ($exceptionThrown) {
|
||||
@@ -53,12 +55,12 @@ class DebuggerSubscriberTest extends \PhraseanetTestCase
|
||||
{
|
||||
return [
|
||||
[false, Application::ENV_PROD, '127.0.0.1', []],
|
||||
[false, Application::ENV_PROD, '192.168.0.1', []],
|
||||
[true, Application::ENV_PROD, '192.168.0.1', []],
|
||||
[false, Application::ENV_DEV, '127.0.0.1', []],
|
||||
[true, Application::ENV_DEV, '192.168.0.1', []],
|
||||
[false, Application::ENV_DEV, '192.168.0.1', ['192.168.0.1']],
|
||||
[false, Application::ENV_TEST, '127.0.0.1', []],
|
||||
[false, Application::ENV_TEST, '192.168.0.1', []],
|
||||
[true, Application::ENV_TEST, '192.168.0.1', []],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user