Commit d7c280e9 authored by Igor Wiedler's avatar Igor Wiedler

[mount] adjust testLazyMount to verify laziness

parent a3a784b2
...@@ -57,17 +57,33 @@ class FunctionalTest extends \PHPUnit_Framework_TestCase ...@@ -57,17 +57,33 @@ class FunctionalTest extends \PHPUnit_Framework_TestCase
public function testLazyMount() public function testLazyMount()
{ {
$mountedFactory = function () { $i = 0;
$mountedFactory = function () use (&$i) {
$i++;
$mounted = new Application(); $mounted = new Application();
$mounted->get('/{name}', function ($name) { return new Response($name); }); $mounted->get('/{name}', function ($name) {
return new Response($name);
});
return $mounted; return $mounted;
}; };
$app = new Application(); $app = new Application();
$app->mount('/hello', $mountedFactory); $app->mount('/hello', $mountedFactory);
$app->get('/main', function() {
return new Response('main app');
});
$response = $app->handle(Request::create('/main'));
$this->assertEquals('main app', $response->getContent());
$this->assertEquals(0, $i);
$response = $app->handle(Request::create('/hello/Silex')); $response = $app->handle(Request::create('/hello/Silex'));
$this->assertEquals('Silex', $response->getContent()); $this->assertEquals('Silex', $response->getContent());
$this->assertEquals(1, $i);
} }
public function testLazyMountWithAnExternalFile() public function testLazyMountWithAnExternalFile()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment