diff --git a/.travis.yml b/.travis.yml
index 576b2bcbd..a2803f0e6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,8 +15,8 @@ matrix:
before_script:
- sudo apt-get install parallel
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- - composer install --dev --prefer-source
- - bin/composer install --dev --prefer-source
+ - composer install --prefer-source
+ - bin/composer install --prefer-source
- git config --global user.name travis-ci
- git config --global user.email travis@example.com
diff --git a/doc/03-cli.md b/doc/03-cli.md
index 3e9ae78e2..e885a7a9f 100644
--- a/doc/03-cli.md
+++ b/doc/03-cli.md
@@ -387,6 +387,7 @@ performance.
* **--optimize (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
autoloader. This is recommended especially for production, but can take
a bit of time to run so it is currently not done by default.
+* **--no-dev:** Disables autoload-dev rules.
## licenses
diff --git a/doc/04-schema.md b/doc/04-schema.md
index ad8b53623..071b3bd9f 100644
--- a/doc/04-schema.md
+++ b/doc/04-schema.md
@@ -518,22 +518,23 @@ Example:
### autoload-dev (root-only)
-This section allows to define autoload rules for development purpose.
+This section allows to define autoload rules for development purposes.
-If you're generating classmaps from your PSR-0 namespaces, you're probably concerned
-about performance, if so, you'll also don't want your test classes to be mixed up
-with your regular classes in those classmaps.
+Classes needed to run the test suite should not be included in the main autoload
+rules to avoid polluting the autoloader in production and when other people use
+your package as a dependency.
-Therefore, it is a good idea to rely on a dedicated path for your unit tests.
+Therefore, it is a good idea to rely on a dedicated path for your unit tests
+and to add it within the autoload-dev section.
Example:
{
"autoload": {
- "psr-0": { "MyLibrary": "src/" }
+ "psr-4": { "MyLibrary\\": "src/" }
},
"autoload-dev": {
- "psr-0": { "MyLibrary\\Tests": "tests/" }
+ "psr-4": { "MyLibrary\\Tests": "tests/" }
}
}
diff --git a/src/Composer/Command/DumpAutoloadCommand.php b/src/Composer/Command/DumpAutoloadCommand.php
index cd3f1b71d..86d351505 100644
--- a/src/Composer/Command/DumpAutoloadCommand.php
+++ b/src/Composer/Command/DumpAutoloadCommand.php
@@ -31,7 +31,7 @@ class DumpAutoloadCommand extends Command
->setDescription('Dumps the autoloader')
->setDefinition(array(
new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 packages to be loaded with classmaps too, good for production.'),
- new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables dev autoload.'),
+ new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'),
))
->setHelp(<<php composer.phar dump-autoload
@@ -61,7 +61,7 @@ EOT
}
$generator = $composer->getAutoloadGenerator();
- $generator->setDevMode($input->getOption('dev'));
+ $generator->setDevMode(!$input->getOption('no-dev'));
$generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
}
}
diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php
index 1bbf0b577..7c4ddccd9 100644
--- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php
+++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php
@@ -170,7 +170,7 @@ class AutoloadGeneratorTest extends TestCase
// Assert that autoload_classmap.php was correctly generated.
$this->assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap');
}
-
+
public function testMainPackageDevAutoloading()
{
$package = new Package('a', '1.0', '1.0');
@@ -181,6 +181,9 @@ class AutoloadGeneratorTest extends TestCase
));
$package->setDevAutoload(array(
'files' => array('devfiles/foo.php'),
+ 'psr-0' => array(
+ 'Main' => 'tests/'
+ ),
));
$this->repository->expects($this->once())
@@ -197,11 +200,11 @@ class AutoloadGeneratorTest extends TestCase
// generate autoload files with the dev mode set to true
$this->generator->setDevMode(true);
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
-
+
// check standard autoload
- $this->assertAutoloadFiles('main4', $this->vendorDir.'/composer');
+ $this->assertAutoloadFiles('main5', $this->vendorDir.'/composer');
$this->assertAutoloadFiles('classmap7', $this->vendorDir.'/composer', 'classmap');
-
+
// make sure dev autoload is correctly dumped
$this->assertAutoloadFiles('files2', $this->vendorDir.'/composer', 'files');
}
@@ -238,7 +241,7 @@ class AutoloadGeneratorTest extends TestCase
// make sure dev autoload is disabled when dev mode is set to false
$this->assertFalse(is_file($this->vendorDir.'/composer/autoload_files.php'));
}
-
+
public function testVendorDirSameAsWorkingDir()
{
$this->vendorDir = $this->workingDir;
diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php b/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php
new file mode 100644
index 000000000..15cb2622b
--- /dev/null
+++ b/tests/Composer/Test/Autoload/Fixtures/autoload_main5.php
@@ -0,0 +1,10 @@
+ array($baseDir . '/src', $baseDir . '/tests'),
+);
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 12caaffac..9e59c65a7 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -12,9 +12,5 @@
error_reporting(E_ALL);
-$loader = require __DIR__.'/../src/bootstrap.php';
-
-// to be removed
-$loader->add('Composer\Test', __DIR__);
-
+require __DIR__.'/../src/bootstrap.php';
require __DIR__.'/Composer/TestCase.php';