8000 [Routing] Fix resource miss · symfony/symfony@1e00afb · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e00afb

Browse files
committed
[Routing] Fix resource miss
1 parent 67a4885 commit 1e00afb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Symfony/Component/Routing/RouteCollectionBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ public function build()
311311
$subCollection->addPrefix($this->prefix);
312312

313313
$routeCollection->addCollection($subCollection);
314+
foreach ($route->resources as $resource) {
315+
$routeCollection->addResource($resource);
316+
}
314317
}
315318

316319
foreach ($this->resources as $resource) {

src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\Routing\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\Config\Resource\FileResource;
17+
use Symfony\Component\Routing\Loader\YamlFileLoader;
1618
use Symfony\Component\Routing\Route;
1719
use Symfony\Component\Routing\RouteCollection;
1820
use Symfony\Component\Routing\RouteCollectionBuilder;
@@ -59,7 +61,18 @@ public function testImport()
5961
$this->assertCount(1, $addedCollection->getResources());
6062

6163
// make sure the routes were imported into the top-level builder
64+
$routeCollection = $routes->build();
6265
$this->assertCount(1, $routes->build());
66+
$this->assertCount(1, $routeCollection->getResources());
67+
}
68+
69+
public function testImportAddResources()
70+
{
71+
$routeCollectionBuilder = new RouteCollectionBuilder(new YamlFileLoader(new FileLocator(array(__DIR__.'/Fixtures/'))));
72+
$routeCollectionBuilder->import('file_resource.yml');
73+
74+
$routeCollection = $routeCollectionBuilder->build();
75+
$this->assertCount(1, $routeCollection->getResources());
6376
}
6477

6578
/**

0 commit comments

Comments
 (0)
0