Skip to content

Commit

Permalink
feature symfony#466 Add support for multiple bundles in auto-generate…
Browse files Browse the repository at this point in the history
…d recipes (emodric)

This PR was merged into the 1.2-dev branch.

Discussion
----------

Add support for multiple bundles in auto-generated recipes

Fixes symfony#427

Commits
-------

aa38671 Add support for multiple bundles in auto-generated recipes
  • Loading branch information
fabpot committed Jan 4, 2019
2 parents 7adc523 + aa38671 commit 48438c2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
15 changes: 5 additions & 10 deletions src/SymfonyBundle.php
Expand Up @@ -32,7 +32,7 @@ public function __construct(Composer $composer, PackageInterface $package, strin

public function getClassNames(): array
{
$all = 'uninstall' === $this->operation;
$uninstall = 'uninstall' === $this->operation;
$classes = [];
$autoload = $this->package->getAutoload();
foreach (['psr-4' => true, 'psr-0' => false] as $psr => $isPsr4) {
Expand All @@ -46,17 +46,12 @@ public function getClassNames(): array
}
foreach ($paths as $path) {
foreach ($this->extractClassNames($namespace) as $class) {
if (!$all) {
// we only check class existence on install as we do have the code available
if (!$this->checkClassExists($class, $path, $isPsr4)) {
continue;
}

return [$class];
// we only check class existence on install as we do have the code available
// in contrast to uninstall operation
if (!$uninstall && !$this->checkClassExists($class, $path, $isPsr4)) {
continue;
}

// on uninstall, we gather all possible values (as we don't have access to the code anymore)
// and try to remove them all from bundles.php
$classes[] = $class;
}
}
Expand Down
Empty file.
Empty file.
25 changes: 15 additions & 10 deletions tests/SymfonyBundleTest.php
Expand Up @@ -20,7 +20,7 @@ class SymfonyBundleTest extends TestCase
/**
* @dataProvider getNamespaces
*/
public function testGetClassNamesForInstall($package, $autoload, $class)
public function testGetClassNamesForInstall($package, $autoload, $classes)
{
$config = $this->getMockBuilder('Composer\Config')->getMock();
$config->expects($this->any())->method('get')->will($this->returnValue(__DIR__.'/Fixtures/vendor'));
Expand All @@ -29,7 +29,7 @@ public function testGetClassNamesForInstall($package, $autoload, $class)
$package = new Package($package, '1.0', '1.0');
$package->setAutoload($autoload);
$bundle = new SymfonyBundle($composer, $package, 'install');
$this->assertContains($class, $bundle->getClassNames());
$this->assertSame($classes, $bundle->getClassNames());
}

public function getNamespaces()
Expand All @@ -38,42 +38,47 @@ public function getNamespaces()
[
'symfony/debug-bundle',
['psr-4' => ['Symfony\\Bundle\\DebugBundle\\' => '']],
'Symfony\\Bundle\\DebugBundle\\DebugBundle',
['Symfony\\Bundle\\DebugBundle\\DebugBundle'],
],
[
'symfony/dummy',
['psr-4' => ['Symfony\\Bundle\\FirstDummyBundle\\' => 'FirstDummyBundle/', 'Symfony\\Bundle\\SecondDummyBundle\\' => 'SecondDummyBundle/']],
['Symfony\\Bundle\\FirstDummyBundle\\FirstDummyBundle', 'Symfony\\Bundle\\SecondDummyBundle\\SecondDummyBundle'],
],
[
'doctrine/doctrine-cache-bundle',
['psr-4' => ['Doctrine\\Bundle\\DoctrineCacheBundle\\' => '']],
'Doctrine\\Bundle\\DoctrineCacheBundle\\DoctrineCacheBundle',
['Doctrine\\Bundle\\DoctrineCacheBundle\\DoctrineCacheBundle'],
],
[
'eightpoints/guzzle-bundle',
['psr-0' => ['EightPoints\\Bundle\\GuzzleBundle' => '']],
'EightPoints\\Bundle\\GuzzleBundle\\GuzzleBundle',
['EightPoints\\Bundle\\GuzzleBundle\\GuzzleBundle'],
],
[
'easycorp/easy-security-bundle',
['psr-4' => ['EasyCorp\\Bundle\\EasySecurityBundle\\' => '']],
'EasyCorp\\Bundle\\EasySecurityBundle\\EasySecurityBundle',
['EasyCorp\\Bundle\\EasySecurityBundle\\EasySecurityBundle'],
],
[
'symfony-cmf/routing-bundle',
['psr-4' => ['Symfony\\Cmf\\Bundle\\RoutingBundle\\' => '']],
'Symfony\\Cmf\\Bundle\\RoutingBundle\\CmfRoutingBundle',
['Symfony\\Cmf\\Bundle\\RoutingBundle\\CmfRoutingBundle'],
],
[
'easycorp/easy-deploy-bundle',
['psr-4' => ['EasyCorp\\Bundle\\EasyDeployBundle\\' => 'src/']],
'EasyCorp\\Bundle\\EasyDeployBundle\\EasyDeployBundle',
['EasyCorp\\Bundle\\EasyDeployBundle\\EasyDeployBundle'],
],
[
'easycorp/easy-deploy-bundle',
['psr-4' => ['EasyCorp\\Bundle\\EasyDeployBundle\\' => ['src', 'tests']]],
'EasyCorp\\Bundle\\EasyDeployBundle\\EasyDeployBundle',
['EasyCorp\\Bundle\\EasyDeployBundle\\EasyDeployBundle'],
],
[
'web-token/jwt-bundle',
['psr-4' => ['Jose\\Bundle\\JoseFramework\\' => ['']]],
'Jose\\Bundle\\JoseFramework\\JoseFrameworkBundle',
['Jose\\Bundle\\JoseFramework\\JoseFrameworkBundle'],
],
];
}
Expand Down

0 comments on commit 48438c2

Please sign in to comment.