diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 71f64b377..e9fc5208b 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -311,9 +311,7 @@ AUTOLOAD; // autoload_real$suffix.php generated by Composer -if (!class_exists('Composer\\\\Autoload\\\\ClassLoader', false)) { - require __DIR__ . '/ClassLoader.php'; -} +require __DIR__ . '/ClassLoader.php'; class ComposerAutoloaderInit$suffix { diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index aaaecbff1..7ab1fe127 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -278,6 +278,9 @@ class AutoloadGeneratorTest extends TestCase $this->assertFileEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php'); $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_realFilesAutoload.php'); + // suppress the class loader to avoid fatals if the class is redefined + file_put_contents($this->vendorDir.'/composer/ClassLoader.php', ''); + include $this->vendorDir . '/autoload.php'; $this->assertTrue(function_exists('testFilesAutoloadGeneration1')); $this->assertTrue(function_exists('testFilesAutoloadGeneration2')); @@ -360,6 +363,9 @@ class AutoloadGeneratorTest extends TestCase $oldIncludePath = get_include_path(); + // suppress the class loader to avoid fatals if the class is redefined + file_put_contents($this->vendorDir.'/composer/ClassLoader.php', ''); + require($this->vendorDir."/autoload.php"); $this->assertEquals( diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php index 49f120ef6..b7fcdd65c 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php @@ -2,9 +2,7 @@ // autoload_realFilesAutoload.php generated by Composer -if (!class_exists('Composer\\Autoload\\ClassLoader', false)) { - require __DIR__ . '/ClassLoader.php'; -} +require __DIR__ . '/ClassLoader.php'; class ComposerAutoloaderInitFilesAutoload { diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php index 2c10eda3a..ed8c68011 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php @@ -2,9 +2,7 @@ // autoload_realTargetDir.php generated by Composer -if (!class_exists('Composer\\Autoload\\ClassLoader', false)) { - require __DIR__ . '/ClassLoader.php'; -} +require __DIR__ . '/ClassLoader.php'; class ComposerAutoloaderInitTargetDir {