From 4f0ad98905f22cbf9c7a18d1b226ab331df306b6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 14 Aug 2012 19:13:39 +0200 Subject: [PATCH] Always include the ClassLoader since autoload_real is included only once, refs #963 --- src/Composer/Autoload/AutoloadGenerator.php | 4 +--- tests/Composer/Test/Autoload/AutoloadGeneratorTest.php | 6 ++++++ .../Test/Autoload/Fixtures/autoload_real_functions.php | 4 +--- .../Test/Autoload/Fixtures/autoload_real_target_dir.php | 4 +--- 4 files changed, 9 insertions(+), 9 deletions(-) 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 {