bug #40098 [DependencyInjection] fix tracking of changes to vendor/ dirs (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[DependencyInjection] fix tracking of changes to vendor/ dirs
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #40092
| License | MIT
| Doc PR | -
Commits
-------
6867475447
[DI] fix tracking of changes to vendor/ dirs
This commit is contained in:
commit
d6219f674f
@ -1655,14 +1655,14 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
private function inVendors(string $path): bool
|
||||
{
|
||||
if (null === $this->vendors) {
|
||||
$resource = new ComposerResource();
|
||||
$this->vendors = $resource->getVendors();
|
||||
$this->addResource($resource);
|
||||
$this->vendors = (new ComposerResource())->getVendors();
|
||||
}
|
||||
$path = realpath($path) ?: $path;
|
||||
|
||||
foreach ($this->vendors as $vendor) {
|
||||
if (0 === strpos($path, $vendor) && false !== strpbrk(substr($path, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) {
|
||||
$this->addResource(new FileResource($vendor.'/composer/installed.json'));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface as PsrContainerInterface;
|
||||
use Symfony\Component\Config\Resource\ComposerResource;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Config\Resource\ResourceInterface;
|
||||
@ -929,7 +928,7 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$resources = $container->getResources();
|
||||
|
||||
$this->assertCount(2, $resources, '2 resources were registered');
|
||||
$this->assertCount(1, $resources);
|
||||
|
||||
/* @var $resource \Symfony\Component\Config\Resource\FileResource */
|
||||
$resource = end($resources);
|
||||
@ -958,9 +957,9 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
$resources = $container->getResources();
|
||||
|
||||
$this->assertCount(3, $resources, '3 resources were registered');
|
||||
$this->assertCount(2, $resources);
|
||||
|
||||
$this->assertSame('reflection.BarClass', (string) $resources[1]);
|
||||
$this->assertSame('reflection.BarClass', (string) $resources[0]);
|
||||
$this->assertSame('BarMissingClass', (string) end($resources));
|
||||
}
|
||||
|
||||
@ -1021,7 +1020,6 @@ class ContainerBuilderTest extends TestCase
|
||||
public function testFileExists()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$A = new ComposerResource();
|
||||
$a = new FileResource(__DIR__.'/Fixtures/xml/services1.xml');
|
||||
$b = new FileResource(__DIR__.'/Fixtures/xml/services2.xml');
|
||||
$c = new DirectoryResource($dir = \dirname($b));
|
||||
@ -1035,7 +1033,7 @@ class ContainerBuilderTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals([$A, $a, $b, $c], $resources, '->getResources() returns an array of resources read for the current configuration');
|
||||
$this->assertEquals([$a, $b, $c], $resources, '->getResources() returns an array of resources read for the current configuration');
|
||||
}
|
||||
|
||||
public function testExtension()
|
||||
|
@ -32,7 +32,7 @@ class GlobFileLoaderTest extends TestCase
|
||||
$loader = new GlobFileLoaderWithoutImport($container = new ContainerBuilder(), new FileLocator());
|
||||
$loader->load(__DIR__.'/../Fixtures/config/*');
|
||||
|
||||
$this->assertEquals(new GlobResource(__DIR__.'/../Fixtures/config', '/*', false), $container->getResources()[1]);
|
||||
$this->assertEquals(new GlobResource(__DIR__.'/../Fixtures/config', '/*', false), $container->getResources()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user