mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Rename mainPackage to rootPackage in AutoloadGenerator and ensure we use RootPackageInterface
This commit is contained in:
parent
07352eafa8
commit
b574f10d9d
11 changed files with 92 additions and 86 deletions
|
@ -20,6 +20,7 @@ use Composer\Semver\Constraint\MatchAllConstraint;
|
|||
use Composer\Util\Filesystem;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\Package;
|
||||
use Composer\Package\RootPackage;
|
||||
use Composer\Test\TestCase;
|
||||
use Composer\Script\ScriptEvents;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
|
@ -159,9 +160,9 @@ class AutoloadGeneratorTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public function testMainPackageAutoloading()
|
||||
public function testRootPackageAutoloading()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array(
|
||||
'Main' => 'src/',
|
||||
|
@ -204,9 +205,9 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$this->assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap');
|
||||
}
|
||||
|
||||
public function testMainPackageDevAutoloading()
|
||||
public function testRootPackageDevAutoloading()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array(
|
||||
'Main' => 'src/',
|
||||
|
@ -242,9 +243,9 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$this->assertAutoloadFiles('files2', $this->vendorDir.'/composer', 'files');
|
||||
}
|
||||
|
||||
public function testMainPackageDevAutoloadingDisabledByDefault()
|
||||
public function testRootPackageDevAutoloadingDisabledByDefault()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array(
|
||||
'Main' => 'src/',
|
||||
|
@ -279,7 +280,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
{
|
||||
$this->vendorDir = $this->workingDir;
|
||||
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
|
||||
'psr-4' => array(
|
||||
|
@ -306,9 +307,9 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$this->assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap');
|
||||
}
|
||||
|
||||
public function testMainPackageAutoloadingAlternativeVendorDir()
|
||||
public function testRootPackageAutoloadingAlternativeVendorDir()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
|
||||
'psr-4' => array(
|
||||
|
@ -335,9 +336,9 @@ class AutoloadGeneratorTest extends TestCase
|
|||
$this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap');
|
||||
}
|
||||
|
||||
public function testMainPackageAutoloadingWithTargetDir()
|
||||
public function testRootPackageAutoloadingWithTargetDir()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => ''),
|
||||
'classmap' => array('Main/Foo/src', 'lib'),
|
||||
|
@ -368,7 +369,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testVendorsAutoloading()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
new Link('a', 'b/b', new MatchAllConstraint()),
|
||||
|
@ -397,7 +398,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testNonDevAutoloadExclusionWithRecursion()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
));
|
||||
|
@ -430,7 +431,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testNonDevAutoloadShouldIncludeReplacedPackages()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(new Link('a', 'a/a', new MatchAllConstraint())));
|
||||
|
||||
$packages = array();
|
||||
|
@ -464,7 +465,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testNonDevAutoloadExclusionWithRecursionReplace()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
));
|
||||
|
@ -497,7 +498,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testNonDevAutoloadReplacesNestedRequirements()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint())
|
||||
));
|
||||
|
@ -549,7 +550,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testPharAutoload()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
));
|
||||
|
@ -590,7 +591,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testPSRToClassMapIgnoresNonExistingDir()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Prefix' => 'foo/bar/non/existing/'),
|
||||
|
@ -613,7 +614,7 @@ class AutoloadGeneratorTest extends TestCase
|
|||
|
||||
public function testPSRToClassMapIgnoresNonPSRClasses()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('psr0_' => 'psr0/'),
|
||||
|
@ -654,7 +655,7 @@ EOF;
|
|||
|
||||
public function testVendorsClassMapAutoloading()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
new Link('a', 'b/b', new MatchAllConstraint()),
|
||||
|
@ -694,7 +695,7 @@ EOF;
|
|||
|
||||
public function testVendorsClassMapAutoloadingWithTargetDir()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
new Link('a', 'b/b', new MatchAllConstraint()),
|
||||
|
@ -734,7 +735,7 @@ EOF;
|
|||
|
||||
public function testClassMapAutoloadingEmptyDirAndExactFile()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
new Link('a', 'b/b', new MatchAllConstraint()),
|
||||
|
@ -779,7 +780,7 @@ EOF;
|
|||
|
||||
public function testClassMapAutoloadingAuthoritativeAndApcu()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
new Link('a', 'b/b', new MatchAllConstraint()),
|
||||
|
@ -828,7 +829,7 @@ EOF;
|
|||
|
||||
public function testClassMapAutoloadingAuthoritativeAndApcuPrefix()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
new Link('a', 'b/b', new MatchAllConstraint()),
|
||||
|
@ -877,7 +878,7 @@ EOF;
|
|||
|
||||
public function testFilesAutoloadGeneration()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array('files' => array('root.php')));
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
|
@ -924,11 +925,11 @@ EOF;
|
|||
|
||||
public function testFilesAutoloadGenerationRemoveExtraEntitiesFromAutoloadFiles()
|
||||
{
|
||||
$autoloadPackage = new Package('a', '1.0', '1.0');
|
||||
$autoloadPackage = new RootPackage('root/a', '1.0', '1.0');
|
||||
$autoloadPackage->setAutoload(array('files' => array('root.php')));
|
||||
$autoloadPackage->setIncludePaths(array('/lib', '/src'));
|
||||
|
||||
$notAutoloadPackage = new Package('a', '1.0', '1.0');
|
||||
$notAutoloadPackage = new RootPackage('root/a', '1.0', '1.0');
|
||||
|
||||
$requires = array(
|
||||
new Link('a', 'a/a', new MatchAllConstraint()),
|
||||
|
@ -999,7 +1000,7 @@ EOF;
|
|||
|
||||
public function testFilesAutoloadOrderByDependencies()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array('files' => array('root2.php')));
|
||||
$package->setRequires(array(
|
||||
new Link('a', 'z/foo', new MatchAllConstraint()),
|
||||
|
@ -1069,12 +1070,12 @@ EOF;
|
|||
*/
|
||||
public function testOverrideVendorsAutoloading()
|
||||
{
|
||||
$mainPackage = new Package('z', '1.0', '1.0');
|
||||
$mainPackage->setAutoload(array(
|
||||
$rootPackage = new RootPackage('root/z', '1.0', '1.0');
|
||||
$rootPackage->setAutoload(array(
|
||||
'psr-0' => array('A\\B' => $this->workingDir.'/lib'),
|
||||
'classmap' => array($this->workingDir.'/src'),
|
||||
));
|
||||
$mainPackage->setRequires(array(
|
||||
$rootPackage->setRequires(array(
|
||||
new Link('z', 'a/a', new MatchAllConstraint()),
|
||||
new Link('z', 'b/b', new MatchAllConstraint()),
|
||||
));
|
||||
|
@ -1156,7 +1157,7 @@ return array(
|
|||
|
||||
EOF;
|
||||
|
||||
$this->generator->dump($this->config, $this->repository, $mainPackage, $this->im, 'composer', true, '_9');
|
||||
$this->generator->dump($this->config, $this->repository, $rootPackage, $this->im, 'composer', true, '_9');
|
||||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
|
||||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
|
||||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
|
||||
|
@ -1164,7 +1165,7 @@ EOF;
|
|||
|
||||
public function testIncludePathFileGeneration()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$packages = array();
|
||||
|
||||
$a = new Package("a/a", "1.0", "1.0");
|
||||
|
@ -1201,7 +1202,7 @@ EOF;
|
|||
|
||||
public function testIncludePathsArePrependedInAutoloadFile()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$packages = array();
|
||||
|
||||
$a = new Package("a/a", "1.0", "1.0");
|
||||
|
@ -1230,9 +1231,9 @@ EOF;
|
|||
set_include_path($oldIncludePath);
|
||||
}
|
||||
|
||||
public function testIncludePathsInMainPackage()
|
||||
public function testIncludePathsInRootPackage()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setIncludePaths(array('/lib', '/src'));
|
||||
|
||||
$packages = array($a = new Package("a/a", "1.0", "1.0"));
|
||||
|
@ -1261,7 +1262,7 @@ EOF;
|
|||
|
||||
public function testIncludePathFileWithoutPathsIsSkipped()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$packages = array();
|
||||
|
||||
$a = new Package("a/a", "1.0", "1.0");
|
||||
|
@ -1290,7 +1291,7 @@ EOF;
|
|||
->method('dispatchScript')
|
||||
->with(ScriptEvents::POST_AUTOLOAD_DUMP, false);
|
||||
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array('psr-0' => array('foo/bar/non/existing/')));
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
|
@ -1303,7 +1304,7 @@ EOF;
|
|||
|
||||
public function testUseGlobalIncludePath()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => ''),
|
||||
));
|
||||
|
@ -1330,7 +1331,7 @@ EOF;
|
|||
$this->fs->ensureDirectoryExists($workingDir);
|
||||
chdir($workingDir);
|
||||
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Foo' => 'src'),
|
||||
'psr-4' => array('Acme\Foo\\' => 'src-psr4'),
|
||||
|
@ -1442,7 +1443,7 @@ EOF;
|
|||
mkdir($workingDir, 0777, true);
|
||||
chdir($workingDir);
|
||||
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Foo' => '../path/../src'),
|
||||
'psr-4' => array('Acme\Foo\\' => '../path/../src-psr4'),
|
||||
|
@ -1516,7 +1517,7 @@ EOF;
|
|||
|
||||
public function testEmptyPaths()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Foo' => ''),
|
||||
'psr-4' => array('Acme\Foo\\' => ''),
|
||||
|
@ -1584,7 +1585,7 @@ EOF;
|
|||
|
||||
public function testVendorSubstringPath()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array('Foo' => 'composer-test-autoload-src/src'),
|
||||
'psr-4' => array('Acme\Foo\\' => 'composer-test-autoload-src/src-psr4'),
|
||||
|
@ -1631,7 +1632,7 @@ EOF;
|
|||
|
||||
public function testExcludeFromClassmap()
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setAutoload(array(
|
||||
'psr-0' => array(
|
||||
'Main' => 'src/',
|
||||
|
@ -1703,7 +1704,7 @@ EOF;
|
|||
*/
|
||||
public function testGeneratesPlatformCheck(array $requires, $expectedFixture, array $provides = array(), array $replaces = array(), $ignorePlatformReqs = false)
|
||||
{
|
||||
$package = new Package('a', '1.0', '1.0');
|
||||
$package = new RootPackage('root/a', '1.0', '1.0');
|
||||
$package->setRequires($requires);
|
||||
|
||||
if ($provides) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue