AutoloadGeneratorTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Autoload;
  12. use Composer\Autoload\AutoloadGenerator;
  13. use Composer\Package\Link;
  14. use Composer\Util\Filesystem;
  15. use Composer\Package\AliasPackage;
  16. use Composer\Package\Package;
  17. use Composer\Test\TestCase;
  18. class AutoloadGeneratorTest extends TestCase
  19. {
  20. public $vendorDir;
  21. private $config;
  22. private $workingDir;
  23. private $im;
  24. private $repository;
  25. private $generator;
  26. private $fs;
  27. protected function setUp()
  28. {
  29. $this->fs = new Filesystem;
  30. $that = $this;
  31. $this->workingDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest';
  32. $this->fs->ensureDirectoryExists($this->workingDir);
  33. $this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload';
  34. $this->ensureDirectoryExistsAndClear($this->vendorDir);
  35. $this->config = $this->getMock('Composer\Config');
  36. $this->config->expects($this->any())
  37. ->method('get')
  38. ->with($this->equalTo('vendor-dir'))
  39. ->will($this->returnCallback(function () use ($that) {
  40. return $that->vendorDir;
  41. }));
  42. $this->dir = getcwd();
  43. chdir($this->workingDir);
  44. $this->im = $this->getMockBuilder('Composer\Installer\InstallationManager')
  45. ->disableOriginalConstructor()
  46. ->getMock();
  47. $this->im->expects($this->any())
  48. ->method('getInstallPath')
  49. ->will($this->returnCallback(function ($package) use ($that) {
  50. return $that->vendorDir.'/'.$package->getName();
  51. }));
  52. $this->repository = $this->getMock('Composer\Repository\RepositoryInterface');
  53. $this->generator = new AutoloadGenerator();
  54. }
  55. protected function tearDown()
  56. {
  57. chdir($this->dir);
  58. if (is_dir($this->workingDir)) {
  59. $this->fs->removeDirectory($this->workingDir);
  60. }
  61. if (is_dir($this->vendorDir)) {
  62. $this->fs->removeDirectory($this->vendorDir);
  63. }
  64. }
  65. public function testMainPackageAutoloading()
  66. {
  67. $package = new Package('a', '1.0', '1.0');
  68. $package->setAutoload(array(
  69. 'psr-0' => array('Main' => 'src/', 'Lala' => array('src/', 'lib/')),
  70. 'classmap' => array('composersrc/'),
  71. ));
  72. $this->repository->expects($this->once())
  73. ->method('getPackages')
  74. ->will($this->returnValue(array()));
  75. $this->fs->ensureDirectoryExists($this->workingDir.'/composer');
  76. $this->fs->ensureDirectoryExists($this->workingDir.'/src');
  77. $this->fs->ensureDirectoryExists($this->workingDir.'/lib');
  78. $this->createClassFile($this->workingDir);
  79. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_1');
  80. $this->assertAutoloadFiles('main', $this->vendorDir.'/composer');
  81. $this->assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap');
  82. }
  83. public function testVendorDirSameAsWorkingDir()
  84. {
  85. $this->vendorDir = $this->workingDir;
  86. $package = new Package('a', '1.0', '1.0');
  87. $package->setAutoload(array(
  88. 'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
  89. 'classmap' => array('composersrc/'),
  90. ));
  91. $this->repository->expects($this->once())
  92. ->method('getPackages')
  93. ->will($this->returnValue(array()));
  94. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  95. $this->fs->ensureDirectoryExists($this->vendorDir.'/src/Main');
  96. file_put_contents($this->vendorDir.'/src/Main/Foo.php', '<?php namespace Main; class Foo {}');
  97. $this->createClassFile($this->vendorDir);
  98. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_2');
  99. $this->assertAutoloadFiles('main3', $this->vendorDir.'/composer');
  100. $this->assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap');
  101. }
  102. public function testMainPackageAutoloadingAlternativeVendorDir()
  103. {
  104. $package = new Package('a', '1.0', '1.0');
  105. $package->setAutoload(array(
  106. 'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
  107. 'classmap' => array('composersrc/'),
  108. ));
  109. $this->repository->expects($this->once())
  110. ->method('getPackages')
  111. ->will($this->returnValue(array()));
  112. $this->vendorDir .= '/subdir';
  113. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  114. $this->fs->ensureDirectoryExists($this->workingDir.'/src');
  115. $this->createClassFile($this->workingDir);
  116. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_3');
  117. $this->assertAutoloadFiles('main2', $this->vendorDir.'/composer');
  118. $this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap');
  119. }
  120. public function testMainPackageAutoloadingWithTargetDir()
  121. {
  122. $package = new Package('a', '1.0', '1.0');
  123. $package->setAutoload(array(
  124. 'psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => ''),
  125. ));
  126. $package->setTargetDir('Main/Foo/');
  127. $this->repository->expects($this->once())
  128. ->method('getPackages')
  129. ->will($this->returnValue(array()));
  130. $this->fs->ensureDirectoryExists($this->vendorDir.'/a');
  131. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDir');
  132. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_target_dir.php', $this->vendorDir.'/autoload.php');
  133. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_target_dir.php', $this->vendorDir.'/composer/autoload_realTargetDir.php');
  134. }
  135. public function testMainPackageAutoloadingWithTargetDirAndNoPsr()
  136. {
  137. $package = new Package('a', '1.0', '1.0');
  138. $package->setAutoload(array(
  139. 'classmap' => array('composersrc/'),
  140. ));
  141. $package->setTargetDir('Main/Foo/');
  142. $this->repository->expects($this->once())
  143. ->method('getPackages')
  144. ->will($this->returnValue(array()));
  145. $this->vendorDir .= '/subdir';
  146. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  147. $this->fs->ensureDirectoryExists($this->workingDir.'/src');
  148. $this->createClassFile($this->workingDir);
  149. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDirNoPsr');
  150. $this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap');
  151. }
  152. public function testVendorsAutoloading()
  153. {
  154. $package = new Package('a', '1.0', '1.0');
  155. $packages = array();
  156. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  157. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  158. $packages[] = $c = new AliasPackage($b, '1.2', '1.2');
  159. $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/')));
  160. $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
  161. $this->repository->expects($this->once())
  162. ->method('getPackages')
  163. ->will($this->returnValue($packages));
  164. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  165. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  166. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib');
  167. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  168. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
  169. $this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer');
  170. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated, even if empty.");
  171. }
  172. public function testVendorsClassMapAutoloading()
  173. {
  174. $package = new Package('a', '1.0', '1.0');
  175. $packages = array();
  176. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  177. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  178. $a->setAutoload(array('classmap' => array('src/')));
  179. $b->setAutoload(array('classmap' => array('src/', 'lib/')));
  180. $this->repository->expects($this->once())
  181. ->method('getPackages')
  182. ->will($this->returnValue($packages));
  183. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  184. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  185. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  186. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/lib');
  187. file_put_contents($this->vendorDir.'/a/a/src/a.php', '<?php class ClassMapFoo {}');
  188. file_put_contents($this->vendorDir.'/b/b/src/b.php', '<?php class ClassMapBar {}');
  189. file_put_contents($this->vendorDir.'/b/b/lib/c.php', '<?php class ClassMapBaz {}');
  190. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
  191. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
  192. $this->assertEquals(
  193. array(
  194. 'ClassMapFoo' => $this->workingDir.'/composer-test-autoload/a/a/src/a.php',
  195. 'ClassMapBar' => $this->workingDir.'/composer-test-autoload/b/b/src/b.php',
  196. 'ClassMapBaz' => $this->workingDir.'/composer-test-autoload/b/b/lib/c.php',
  197. ),
  198. include ($this->vendorDir.'/composer/autoload_classmap.php')
  199. );
  200. $this->assertAutoloadFiles('classmap4', $this->vendorDir.'/composer', 'classmap');
  201. }
  202. public function testClassMapAutoloadingEmptyDirAndExactFile()
  203. {
  204. $package = new Package('a', '1.0', '1.0');
  205. $packages = array();
  206. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  207. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  208. $packages[] = $c = new Package('c/c', '1.0', '1.0');
  209. $a->setAutoload(array('classmap' => array('')));
  210. $b->setAutoload(array('classmap' => array('test.php')));
  211. $c->setAutoload(array('classmap' => array('./')));
  212. $this->repository->expects($this->once())
  213. ->method('getPackages')
  214. ->will($this->returnValue($packages));
  215. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  216. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  217. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b');
  218. $this->fs->ensureDirectoryExists($this->vendorDir.'/c/c/foo');
  219. file_put_contents($this->vendorDir.'/a/a/src/a.php', '<?php class ClassMapFoo {}');
  220. file_put_contents($this->vendorDir.'/b/b/test.php', '<?php class ClassMapBar {}');
  221. file_put_contents($this->vendorDir.'/c/c/foo/test.php', '<?php class ClassMapBaz {}');
  222. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7');
  223. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
  224. $this->assertEquals(
  225. array(
  226. 'ClassMapFoo' => $this->workingDir.'/composer-test-autoload/a/a/src/a.php',
  227. 'ClassMapBar' => $this->workingDir.'/composer-test-autoload/b/b/test.php',
  228. 'ClassMapBaz' => $this->workingDir.'/composer-test-autoload/c/c/foo/test.php',
  229. ),
  230. include ($this->vendorDir.'/composer/autoload_classmap.php')
  231. );
  232. $this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap');
  233. }
  234. public function testFilesAutoloadGeneration()
  235. {
  236. $package = new Package('a', '1.0', '1.0');
  237. $package->setAutoload(array('files' => array('root.php')));
  238. $packages = array();
  239. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  240. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  241. $a->setAutoload(array('files' => array('test.php')));
  242. $b->setAutoload(array('files' => array('test2.php')));
  243. $this->repository->expects($this->once())
  244. ->method('getPackages')
  245. ->will($this->returnValue($packages));
  246. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a');
  247. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b');
  248. file_put_contents($this->vendorDir.'/a/a/test.php', '<?php function testFilesAutoloadGeneration1() {}');
  249. file_put_contents($this->vendorDir.'/b/b/test2.php', '<?php function testFilesAutoloadGeneration2() {}');
  250. file_put_contents($this->workingDir.'/root.php', '<?php function testFilesAutoloadGenerationRoot() {}');
  251. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoload');
  252. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php');
  253. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_realFilesAutoload.php');
  254. // suppress the class loader to avoid fatals if the class is redefined
  255. file_put_contents($this->vendorDir.'/composer/ClassLoader.php', '');
  256. include $this->vendorDir . '/autoload.php';
  257. $this->assertTrue(function_exists('testFilesAutoloadGeneration1'));
  258. $this->assertTrue(function_exists('testFilesAutoloadGeneration2'));
  259. $this->assertTrue(function_exists('testFilesAutoloadGenerationRoot'));
  260. }
  261. public function testFilesAutoloadOrderByDependencies()
  262. {
  263. $package = new Package('a', '1.0', '1.0');
  264. $package->setAutoload(array('files' => array('root.php')));
  265. $package->setRequires(array(new Link('a', 'a/foo')));
  266. $packages = array();
  267. $packages[] = $a = new Package('a/foo', '1.0', '1.0');
  268. $packages[] = $b = new Package('b/bar', '1.0', '1.0');
  269. $packages[] = $c = new Package('c/lorem', '1.0', '1.0');
  270. $a->setAutoload(array('files' => array('testA.php')));
  271. $a->setRequires(array(new Link('a/foo', 'c/lorem')));
  272. $b->setAutoload(array('files' => array('testB.php')));
  273. $b->setRequires(array(new Link('b/bar', 'c/lorem')));
  274. $c->setAutoload(array('files' => array('testC.php')));
  275. $this->repository->expects($this->once())
  276. ->method('getPackages')
  277. ->will($this->returnValue($packages));
  278. $this->fs->ensureDirectoryExists($this->vendorDir . '/a/foo');
  279. $this->fs->ensureDirectoryExists($this->vendorDir . '/b/bar');
  280. $this->fs->ensureDirectoryExists($this->vendorDir . '/c/lorem');
  281. file_put_contents($this->vendorDir . '/a/foo/testA.php', '<?php function testFilesAutoloadOrderByDependency1() {}');
  282. file_put_contents($this->vendorDir . '/b/bar/testB.php', '<?php function testFilesAutoloadOrderByDependency2() {}');
  283. file_put_contents($this->vendorDir . '/c/lorem/testC.php', '<?php function testFilesAutoloadOrderByDependency3() {}');
  284. file_put_contents($this->workingDir . '/root.php', '<?php function testFilesAutoloadOrderByDependencyRoot() {}');
  285. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoloadOrder');
  286. $this->assertFileEquals(__DIR__ . '/Fixtures/autoload_functions_by_dependency.php', $this->vendorDir . '/autoload.php');
  287. $this->assertFileEquals(__DIR__ . '/Fixtures/autoload_real_files_by_dependency.php', $this->vendorDir . '/composer/autoload_realFilesAutoloadOrder.php');
  288. // suppress the class loader to avoid fatals if the class is redefined
  289. file_put_contents($this->vendorDir . '/composer/ClassLoader.php', '');
  290. include $this->vendorDir . '/autoload.php';
  291. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency1'));
  292. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency2'));
  293. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency3'));
  294. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot'));
  295. }
  296. public function testOverrideVendorsAutoloading()
  297. {
  298. $package = new Package('a', '1.0', '1.0');
  299. $package->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir.'/lib')));
  300. $packages = array();
  301. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  302. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  303. $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/')));
  304. $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
  305. $this->repository->expects($this->once())
  306. ->method('getPackages')
  307. ->will($this->returnValue($packages));
  308. $this->fs->ensureDirectoryExists($this->workingDir.'/lib/A/B');
  309. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  310. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  311. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib/A/B');
  312. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  313. file_put_contents($this->workingDir.'/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
  314. file_put_contents($this->vendorDir.'/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
  315. $workDir = strtr($this->workingDir, '\\', '/');
  316. $expectedNamespace = <<<EOF
  317. <?php
  318. // autoload_namespaces.php generated by Composer
  319. \$vendorDir = dirname(__DIR__);
  320. \$baseDir = dirname(\$vendorDir);
  321. return array(
  322. 'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src/',
  323. 'A\\\\B' => array('$workDir/lib', \$vendorDir . '/a/a/lib/'),
  324. 'A' => \$vendorDir . '/a/a/src/',
  325. );
  326. EOF;
  327. $expectedClassmap = <<<EOF
  328. <?php
  329. // autoload_classmap.php generated by Composer
  330. \$vendorDir = dirname(__DIR__);
  331. \$baseDir = dirname(\$vendorDir);
  332. return array(
  333. 'A\\\\B\\\\C' => \$baseDir . '/lib/A/B/C.php',
  334. );
  335. EOF;
  336. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_9');
  337. $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
  338. $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
  339. }
  340. public function testIncludePathFileGeneration()
  341. {
  342. $package = new Package('a', '1.0', '1.0');
  343. $packages = array();
  344. $a = new Package("a/a", "1.0", "1.0");
  345. $a->setIncludePaths(array("lib/"));
  346. $b = new Package("b/b", "1.0", "1.0");
  347. $b->setIncludePaths(array("library"));
  348. $c = new Package("c", "1.0", "1.0");
  349. $c->setIncludePaths(array("library"));
  350. $packages[] = $a;
  351. $packages[] = $b;
  352. $packages[] = $c;
  353. $this->repository->expects($this->once())
  354. ->method("getPackages")
  355. ->will($this->returnValue($packages));
  356. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  357. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_10');
  358. $this->assertFileEquals(__DIR__.'/Fixtures/include_paths.php', $this->vendorDir.'/composer/include_paths.php');
  359. $this->assertEquals(
  360. array(
  361. $this->vendorDir."/a/a/lib",
  362. $this->vendorDir."/b/b/library",
  363. $this->vendorDir."/c/library",
  364. ),
  365. require($this->vendorDir."/composer/include_paths.php")
  366. );
  367. }
  368. public function testIncludePathsArePrependedInAutoloadFile()
  369. {
  370. $package = new Package('a', '1.0', '1.0');
  371. $packages = array();
  372. $a = new Package("a/a", "1.0", "1.0");
  373. $a->setIncludePaths(array("lib/"));
  374. $packages[] = $a;
  375. $this->repository->expects($this->once())
  376. ->method("getPackages")
  377. ->will($this->returnValue($packages));
  378. mkdir($this->vendorDir."/composer", 0777, true);
  379. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_11');
  380. $oldIncludePath = get_include_path();
  381. // suppress the class loader to avoid fatals if the class is redefined
  382. file_put_contents($this->vendorDir.'/composer/ClassLoader.php', '');
  383. require($this->vendorDir."/autoload.php");
  384. $this->assertEquals(
  385. $this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath,
  386. get_include_path()
  387. );
  388. set_include_path($oldIncludePath);
  389. }
  390. public function testIncludePathFileWithoutPathsIsSkipped()
  391. {
  392. $package = new Package('a', '1.0', '1.0');
  393. $packages = array();
  394. $a = new Package("a/a", "1.0", "1.0");
  395. $packages[] = $a;
  396. $this->repository->expects($this->once())
  397. ->method("getPackages")
  398. ->will($this->returnValue($packages));
  399. mkdir($this->vendorDir."/composer", 0777, true);
  400. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12');
  401. $this->assertFalse(file_exists($this->vendorDir."/composer/include_paths.php"));
  402. }
  403. private function createClassFile($basedir)
  404. {
  405. if (!is_dir($basedir.'/composersrc')) {
  406. mkdir($basedir.'/composersrc', 0777, true);
  407. }
  408. file_put_contents($basedir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
  409. }
  410. private function assertAutoloadFiles($name, $dir, $type = 'namespaces')
  411. {
  412. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_'.$name.'.php', $dir.'/autoload_'.$type.'.php');
  413. }
  414. }