AutoloadGeneratorTest.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  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\TestCase;
  18. use Composer\Script\ScriptEvents;
  19. class AutoloadGeneratorTest extends TestCase
  20. {
  21. public $vendorDir;
  22. private $config;
  23. private $workingDir;
  24. private $im;
  25. private $repository;
  26. private $generator;
  27. private $fs;
  28. private $eventDispatcher;
  29. protected function setUp()
  30. {
  31. $this->fs = new Filesystem;
  32. $that = $this;
  33. $this->workingDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest-'.md5(uniqid('', true));
  34. $this->fs->ensureDirectoryExists($this->workingDir);
  35. $this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload';
  36. $this->ensureDirectoryExistsAndClear($this->vendorDir);
  37. $this->config = $this->getMock('Composer\Config');
  38. $this->config->expects($this->at(0))
  39. ->method('get')
  40. ->with($this->equalTo('vendor-dir'))
  41. ->will($this->returnCallback(function () use ($that) {
  42. return $that->vendorDir;
  43. }));
  44. $this->config->expects($this->at(1))
  45. ->method('get')
  46. ->with($this->equalTo('vendor-dir'))
  47. ->will($this->returnCallback(function () use ($that) {
  48. return $that->vendorDir;
  49. }));
  50. $this->origDir = getcwd();
  51. chdir($this->workingDir);
  52. $this->im = $this->getMockBuilder('Composer\Installer\InstallationManager')
  53. ->disableOriginalConstructor()
  54. ->getMock();
  55. $this->im->expects($this->any())
  56. ->method('getInstallPath')
  57. ->will($this->returnCallback(function ($package) use ($that) {
  58. $targetDir = $package->getTargetDir();
  59. return $that->vendorDir.'/'.$package->getName() . ($targetDir ? '/'.$targetDir : '');
  60. }));
  61. $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
  62. $this->eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
  63. ->disableOriginalConstructor()
  64. ->getMock();
  65. $this->generator = new AutoloadGenerator($this->eventDispatcher);
  66. }
  67. protected function tearDown()
  68. {
  69. chdir($this->origDir);
  70. if (is_dir($this->workingDir)) {
  71. $this->fs->removeDirectory($this->workingDir);
  72. }
  73. if (is_dir($this->vendorDir)) {
  74. $this->fs->removeDirectory($this->vendorDir);
  75. }
  76. }
  77. public function testMainPackageAutoloading()
  78. {
  79. $package = new Package('a', '1.0', '1.0');
  80. $package->setAutoload(array(
  81. 'psr-0' => array(
  82. 'Main' => 'src/',
  83. 'Lala' => array('src/', 'lib/'),
  84. ),
  85. 'psr-4' => array(
  86. 'Acme\Fruit\\' => 'src-fruit/',
  87. 'Acme\Cake\\' => array('src-cake/', 'lib-cake/'),
  88. ),
  89. 'classmap' => array('composersrc/'),
  90. ));
  91. $this->repository->expects($this->once())
  92. ->method('getCanonicalPackages')
  93. ->will($this->returnValue(array()));
  94. $this->fs->ensureDirectoryExists($this->workingDir.'/composer');
  95. $this->fs->ensureDirectoryExists($this->workingDir.'/src');
  96. $this->fs->ensureDirectoryExists($this->workingDir.'/lib');
  97. $this->fs->ensureDirectoryExists($this->workingDir.'/src-fruit');
  98. $this->fs->ensureDirectoryExists($this->workingDir.'/src-cake');
  99. $this->fs->ensureDirectoryExists($this->workingDir.'/lib-cake');
  100. $this->fs->ensureDirectoryExists($this->workingDir.'/composersrc');
  101. file_put_contents($this->workingDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
  102. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_1');
  103. // Assert that autoload_namespaces.php was correctly generated.
  104. $this->assertAutoloadFiles('main', $this->vendorDir.'/composer');
  105. // Assert that autoload_psr4.php was correctly generated.
  106. $this->assertAutoloadFiles('psr4', $this->vendorDir.'/composer', 'psr4');
  107. // Assert that autoload_classmap.php was correctly generated.
  108. $this->assertAutoloadFiles('classmap', $this->vendorDir.'/composer', 'classmap');
  109. }
  110. public function testVendorDirSameAsWorkingDir()
  111. {
  112. $this->vendorDir = $this->workingDir;
  113. $package = new Package('a', '1.0', '1.0');
  114. $package->setAutoload(array(
  115. 'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
  116. 'psr-4' => array(
  117. 'Acme\Fruit\\' => 'src-fruit/',
  118. 'Acme\Cake\\' => array('src-cake/', 'lib-cake/'),
  119. ),
  120. 'classmap' => array('composersrc/'),
  121. ));
  122. $this->repository->expects($this->once())
  123. ->method('getCanonicalPackages')
  124. ->will($this->returnValue(array()));
  125. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  126. $this->fs->ensureDirectoryExists($this->vendorDir.'/src/Main');
  127. file_put_contents($this->vendorDir.'/src/Main/Foo.php', '<?php namespace Main; class Foo {}');
  128. $this->fs->ensureDirectoryExists($this->vendorDir.'/composersrc');
  129. file_put_contents($this->vendorDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
  130. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_2');
  131. $this->assertAutoloadFiles('main3', $this->vendorDir.'/composer');
  132. $this->assertAutoloadFiles('psr4_3', $this->vendorDir.'/composer', 'psr4');
  133. $this->assertAutoloadFiles('classmap3', $this->vendorDir.'/composer', 'classmap');
  134. }
  135. public function testMainPackageAutoloadingAlternativeVendorDir()
  136. {
  137. $package = new Package('a', '1.0', '1.0');
  138. $package->setAutoload(array(
  139. 'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
  140. 'psr-4' => array(
  141. 'Acme\Fruit\\' => 'src-fruit/',
  142. 'Acme\Cake\\' => array('src-cake/', 'lib-cake/'),
  143. ),
  144. 'classmap' => array('composersrc/'),
  145. ));
  146. $this->repository->expects($this->once())
  147. ->method('getCanonicalPackages')
  148. ->will($this->returnValue(array()));
  149. $this->vendorDir .= '/subdir';
  150. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  151. $this->fs->ensureDirectoryExists($this->workingDir.'/src');
  152. $this->fs->ensureDirectoryExists($this->workingDir.'/composersrc');
  153. file_put_contents($this->workingDir.'/composersrc/foo.php', '<?php class ClassMapFoo {}');
  154. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_3');
  155. $this->assertAutoloadFiles('main2', $this->vendorDir.'/composer');
  156. $this->assertAutoloadFiles('psr4_2', $this->vendorDir.'/composer', 'psr4');
  157. $this->assertAutoloadFiles('classmap2', $this->vendorDir.'/composer', 'classmap');
  158. }
  159. public function testMainPackageAutoloadingWithTargetDir()
  160. {
  161. $package = new Package('a', '1.0', '1.0');
  162. $package->setAutoload(array(
  163. 'psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => ''),
  164. 'classmap' => array('Main/Foo/src', 'lib'),
  165. 'files' => array('foo.php', 'Main/Foo/bar.php'),
  166. ));
  167. $package->setTargetDir('Main/Foo/');
  168. $this->repository->expects($this->once())
  169. ->method('getCanonicalPackages')
  170. ->will($this->returnValue(array()));
  171. $this->fs->ensureDirectoryExists($this->vendorDir.'/a');
  172. $this->fs->ensureDirectoryExists($this->workingDir.'/src');
  173. $this->fs->ensureDirectoryExists($this->workingDir.'/lib');
  174. file_put_contents($this->workingDir.'/src/rootfoo.php', '<?php class ClassMapFoo {}');
  175. file_put_contents($this->workingDir.'/lib/rootbar.php', '<?php class ClassMapBar {}');
  176. file_put_contents($this->workingDir.'/foo.php', '<?php class FilesFoo {}');
  177. file_put_contents($this->workingDir.'/bar.php', '<?php class FilesBar {}');
  178. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'TargetDir');
  179. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_target_dir.php', $this->vendorDir.'/autoload.php');
  180. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_target_dir.php', $this->vendorDir.'/composer/autoload_real.php');
  181. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_files_target_dir.php', $this->vendorDir.'/composer/autoload_files.php');
  182. $this->assertAutoloadFiles('classmap6', $this->vendorDir.'/composer', 'classmap');
  183. }
  184. public function testVendorsAutoloading()
  185. {
  186. $package = new Package('a', '1.0', '1.0');
  187. $packages = array();
  188. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  189. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  190. $packages[] = $c = new AliasPackage($b, '1.2', '1.2');
  191. $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/')));
  192. $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
  193. $this->repository->expects($this->once())
  194. ->method('getCanonicalPackages')
  195. ->will($this->returnValue($packages));
  196. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  197. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  198. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib');
  199. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  200. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_5');
  201. $this->assertAutoloadFiles('vendors', $this->vendorDir.'/composer');
  202. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated, even if empty.");
  203. }
  204. public function testPSRToClassMapIgnoresNonExistingDir()
  205. {
  206. $package = new Package('a', '1.0', '1.0');
  207. $package->setAutoload(array(
  208. 'psr-0' => array('Prefix' => 'foo/bar/non/existing/'),
  209. 'psr-4' => array('Prefix\\' => 'foo/bar/non/existing2/')
  210. ));
  211. $this->repository->expects($this->once())
  212. ->method('getCanonicalPackages')
  213. ->will($this->returnValue(array()));
  214. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8');
  215. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
  216. $this->assertEquals(
  217. array(),
  218. include $this->vendorDir.'/composer/autoload_classmap.php'
  219. );
  220. }
  221. public function testVendorsClassMapAutoloading()
  222. {
  223. $package = new Package('a', '1.0', '1.0');
  224. $packages = array();
  225. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  226. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  227. $a->setAutoload(array('classmap' => array('src/')));
  228. $b->setAutoload(array('classmap' => array('src/', 'lib/')));
  229. $this->repository->expects($this->once())
  230. ->method('getCanonicalPackages')
  231. ->will($this->returnValue($packages));
  232. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  233. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  234. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  235. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/lib');
  236. file_put_contents($this->vendorDir.'/a/a/src/a.php', '<?php class ClassMapFoo {}');
  237. file_put_contents($this->vendorDir.'/b/b/src/b.php', '<?php class ClassMapBar {}');
  238. file_put_contents($this->vendorDir.'/b/b/lib/c.php', '<?php class ClassMapBaz {}');
  239. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
  240. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
  241. $this->assertEquals(
  242. array(
  243. 'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php',
  244. 'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.php',
  245. 'ClassMapFoo' => $this->vendorDir.'/a/a/src/a.php',
  246. ),
  247. include $this->vendorDir.'/composer/autoload_classmap.php'
  248. );
  249. $this->assertAutoloadFiles('classmap4', $this->vendorDir.'/composer', 'classmap');
  250. }
  251. public function testVendorsClassMapAutoloadingWithTargetDir()
  252. {
  253. $package = new Package('a', '1.0', '1.0');
  254. $packages = array();
  255. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  256. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  257. $a->setAutoload(array('classmap' => array('target/src/', 'lib/')));
  258. $a->setTargetDir('target');
  259. $b->setAutoload(array('classmap' => array('src/')));
  260. $this->repository->expects($this->once())
  261. ->method('getCanonicalPackages')
  262. ->will($this->returnValue($packages));
  263. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  264. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/target/src');
  265. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/target/lib');
  266. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  267. file_put_contents($this->vendorDir.'/a/a/target/src/a.php', '<?php class ClassMapFoo {}');
  268. file_put_contents($this->vendorDir.'/a/a/target/lib/b.php', '<?php class ClassMapBar {}');
  269. file_put_contents($this->vendorDir.'/b/b/src/c.php', '<?php class ClassMapBaz {}');
  270. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
  271. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
  272. $this->assertEquals(
  273. array(
  274. 'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php',
  275. 'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.php',
  276. 'ClassMapFoo' => $this->vendorDir.'/a/a/target/src/a.php',
  277. ),
  278. include $this->vendorDir.'/composer/autoload_classmap.php'
  279. );
  280. }
  281. public function testClassMapAutoloadingEmptyDirAndExactFile()
  282. {
  283. $package = new Package('a', '1.0', '1.0');
  284. $packages = array();
  285. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  286. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  287. $packages[] = $c = new Package('c/c', '1.0', '1.0');
  288. $a->setAutoload(array('classmap' => array('')));
  289. $b->setAutoload(array('classmap' => array('test.php')));
  290. $c->setAutoload(array('classmap' => array('./')));
  291. $this->repository->expects($this->once())
  292. ->method('getCanonicalPackages')
  293. ->will($this->returnValue($packages));
  294. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  295. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  296. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b');
  297. $this->fs->ensureDirectoryExists($this->vendorDir.'/c/c/foo');
  298. file_put_contents($this->vendorDir.'/a/a/src/a.php', '<?php class ClassMapFoo {}');
  299. file_put_contents($this->vendorDir.'/b/b/test.php', '<?php class ClassMapBar {}');
  300. file_put_contents($this->vendorDir.'/c/c/foo/test.php', '<?php class ClassMapBaz {}');
  301. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7');
  302. $this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
  303. $this->assertEquals(
  304. array(
  305. 'ClassMapBar' => $this->vendorDir.'/b/b/test.php',
  306. 'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.php',
  307. 'ClassMapFoo' => $this->vendorDir.'/a/a/src/a.php',
  308. ),
  309. include $this->vendorDir.'/composer/autoload_classmap.php'
  310. );
  311. $this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap');
  312. }
  313. public function testFilesAutoloadGeneration()
  314. {
  315. $package = new Package('a', '1.0', '1.0');
  316. $package->setAutoload(array('files' => array('root.php')));
  317. $packages = array();
  318. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  319. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  320. $packages[] = $c = new Package('c/c', '1.0', '1.0');
  321. $a->setAutoload(array('files' => array('test.php')));
  322. $b->setAutoload(array('files' => array('test2.php')));
  323. $c->setAutoload(array('files' => array('test3.php', 'foo/bar/test4.php')));
  324. $c->setTargetDir('foo/bar');
  325. $this->repository->expects($this->once())
  326. ->method('getCanonicalPackages')
  327. ->will($this->returnValue($packages));
  328. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a');
  329. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b');
  330. $this->fs->ensureDirectoryExists($this->vendorDir.'/c/c/foo/bar');
  331. file_put_contents($this->vendorDir.'/a/a/test.php', '<?php function testFilesAutoloadGeneration1() {}');
  332. file_put_contents($this->vendorDir.'/b/b/test2.php', '<?php function testFilesAutoloadGeneration2() {}');
  333. file_put_contents($this->vendorDir.'/c/c/foo/bar/test3.php', '<?php function testFilesAutoloadGeneration3() {}');
  334. file_put_contents($this->vendorDir.'/c/c/foo/bar/test4.php', '<?php function testFilesAutoloadGeneration4() {}');
  335. file_put_contents($this->workingDir.'/root.php', '<?php function testFilesAutoloadGenerationRoot() {}');
  336. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoload');
  337. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php');
  338. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_real.php');
  339. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_files_functions.php', $this->vendorDir.'/composer/autoload_files.php');
  340. include $this->vendorDir . '/autoload.php';
  341. $this->assertTrue(function_exists('testFilesAutoloadGeneration1'));
  342. $this->assertTrue(function_exists('testFilesAutoloadGeneration2'));
  343. $this->assertTrue(function_exists('testFilesAutoloadGeneration3'));
  344. $this->assertTrue(function_exists('testFilesAutoloadGeneration4'));
  345. $this->assertTrue(function_exists('testFilesAutoloadGenerationRoot'));
  346. }
  347. public function testFilesAutoloadOrderByDependencies()
  348. {
  349. $package = new Package('a', '1.0', '1.0');
  350. $package->setAutoload(array('files' => array('root.php')));
  351. $package->setRequires(array(new Link('a', 'z/foo')));
  352. $package->setRequires(array(new Link('a', 'd/d')));
  353. $package->setRequires(array(new Link('a', 'e/e')));
  354. $packages = array();
  355. $packages[] = $z = new Package('z/foo', '1.0', '1.0');
  356. $packages[] = $b = new Package('b/bar', '1.0', '1.0');
  357. $packages[] = $d = new Package('d/d', '1.0', '1.0');
  358. $packages[] = $c = new Package('c/lorem', '1.0', '1.0');
  359. $packages[] = $e = new Package('e/e', '1.0', '1.0');
  360. $z->setAutoload(array('files' => array('testA.php')));
  361. $z->setRequires(array(new Link('z/foo', 'c/lorem')));
  362. $b->setAutoload(array('files' => array('testB.php')));
  363. $b->setRequires(array(new Link('b/bar', 'c/lorem'), new Link('b/bar', 'd/d')));
  364. $c->setAutoload(array('files' => array('testC.php')));
  365. $d->setAutoload(array('files' => array('testD.php')));
  366. $d->setRequires(array(new Link('d/d', 'c/lorem')));
  367. $e->setAutoload(array('files' => array('testE.php')));
  368. $e->setRequires(array(new Link('e/e', 'c/lorem')));
  369. $this->repository->expects($this->once())
  370. ->method('getCanonicalPackages')
  371. ->will($this->returnValue($packages));
  372. $this->fs->ensureDirectoryExists($this->vendorDir . '/z/foo');
  373. $this->fs->ensureDirectoryExists($this->vendorDir . '/b/bar');
  374. $this->fs->ensureDirectoryExists($this->vendorDir . '/c/lorem');
  375. $this->fs->ensureDirectoryExists($this->vendorDir . '/d/d');
  376. $this->fs->ensureDirectoryExists($this->vendorDir . '/e/e');
  377. file_put_contents($this->vendorDir . '/z/foo/testA.php', '<?php function testFilesAutoloadOrderByDependency1() {}');
  378. file_put_contents($this->vendorDir . '/b/bar/testB.php', '<?php function testFilesAutoloadOrderByDependency2() {}');
  379. file_put_contents($this->vendorDir . '/c/lorem/testC.php', '<?php function testFilesAutoloadOrderByDependency3() {}');
  380. file_put_contents($this->vendorDir . '/d/d/testD.php', '<?php function testFilesAutoloadOrderByDependency4() {}');
  381. file_put_contents($this->vendorDir . '/e/e/testE.php', '<?php function testFilesAutoloadOrderByDependency5() {}');
  382. file_put_contents($this->workingDir . '/root.php', '<?php function testFilesAutoloadOrderByDependencyRoot() {}');
  383. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoloadOrder');
  384. $this->assertFileEquals(__DIR__ . '/Fixtures/autoload_functions_by_dependency.php', $this->vendorDir . '/autoload.php');
  385. $this->assertFileEquals(__DIR__ . '/Fixtures/autoload_real_files_by_dependency.php', $this->vendorDir . '/composer/autoload_real.php');
  386. require $this->vendorDir . '/autoload.php';
  387. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency1'));
  388. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency2'));
  389. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency3'));
  390. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency4'));
  391. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency5'));
  392. $this->assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot'));
  393. }
  394. public function testOverrideVendorsAutoloading()
  395. {
  396. $package = new Package('z', '1.0', '1.0');
  397. $package->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir.'/lib'), 'classmap' => array($this->workingDir.'/src')));
  398. $package->setRequires(array(new Link('z', 'a/a')));
  399. $packages = array();
  400. $packages[] = $a = new Package('a/a', '1.0', '1.0');
  401. $packages[] = $b = new Package('b/b', '1.0', '1.0');
  402. $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'), 'classmap' => array('classmap')));
  403. $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
  404. $this->repository->expects($this->once())
  405. ->method('getCanonicalPackages')
  406. ->will($this->returnValue($packages));
  407. $this->fs->ensureDirectoryExists($this->workingDir.'/lib/A/B');
  408. $this->fs->ensureDirectoryExists($this->workingDir.'/src/');
  409. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  410. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/classmap');
  411. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/src');
  412. $this->fs->ensureDirectoryExists($this->vendorDir.'/a/a/lib/A/B');
  413. $this->fs->ensureDirectoryExists($this->vendorDir.'/b/b/src');
  414. file_put_contents($this->workingDir.'/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
  415. file_put_contents($this->workingDir.'/src/classes.php', '<?php namespace Foo; class Bar {}');
  416. file_put_contents($this->vendorDir.'/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
  417. file_put_contents($this->vendorDir.'/a/a/classmap/classes.php', '<?php namespace Foo; class Bar {}');
  418. $expectedNamespace = <<<EOF
  419. <?php
  420. // autoload_namespaces.php @generated by Composer
  421. \$vendorDir = dirname(dirname(__FILE__));
  422. \$baseDir = dirname(\$vendorDir);
  423. return array(
  424. 'B\\\\Sub\\\\Name' => array(\$vendorDir . '/b/b/src'),
  425. 'A\\\\B' => array(\$baseDir . '/lib', \$vendorDir . '/a/a/lib'),
  426. 'A' => array(\$vendorDir . '/a/a/src'),
  427. );
  428. EOF;
  429. // autoload_psr4.php is expected to be empty in this example.
  430. $expectedPsr4 = <<<EOF
  431. <?php
  432. // autoload_psr4.php @generated by Composer
  433. \$vendorDir = dirname(dirname(__FILE__));
  434. \$baseDir = dirname(\$vendorDir);
  435. return array(
  436. );
  437. EOF;
  438. $expectedClassmap = <<<EOF
  439. <?php
  440. // autoload_classmap.php @generated by Composer
  441. \$vendorDir = dirname(dirname(__FILE__));
  442. \$baseDir = dirname(\$vendorDir);
  443. return array(
  444. 'A\\\\B\\\\C' => \$baseDir . '/lib/A/B/C.php',
  445. 'Foo\\\\Bar' => \$baseDir . '/src/classes.php',
  446. );
  447. EOF;
  448. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_9');
  449. $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
  450. $this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir.'/composer/autoload_psr4.php'));
  451. $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
  452. }
  453. public function testIncludePathFileGeneration()
  454. {
  455. $package = new Package('a', '1.0', '1.0');
  456. $packages = array();
  457. $a = new Package("a/a", "1.0", "1.0");
  458. $a->setIncludePaths(array("lib/"));
  459. $b = new Package("b/b", "1.0", "1.0");
  460. $b->setIncludePaths(array("library"));
  461. $c = new Package("c", "1.0", "1.0");
  462. $c->setIncludePaths(array("library"));
  463. $packages[] = $a;
  464. $packages[] = $b;
  465. $packages[] = $c;
  466. $this->repository->expects($this->once())
  467. ->method("getCanonicalPackages")
  468. ->will($this->returnValue($packages));
  469. $this->fs->ensureDirectoryExists($this->vendorDir.'/composer');
  470. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_10');
  471. $this->assertFileEquals(__DIR__.'/Fixtures/include_paths.php', $this->vendorDir.'/composer/include_paths.php');
  472. $this->assertEquals(
  473. array(
  474. $this->vendorDir."/a/a/lib",
  475. $this->vendorDir."/b/b/library",
  476. $this->vendorDir."/c/library",
  477. ),
  478. require $this->vendorDir."/composer/include_paths.php"
  479. );
  480. }
  481. public function testIncludePathsArePrependedInAutoloadFile()
  482. {
  483. $package = new Package('a', '1.0', '1.0');
  484. $packages = array();
  485. $a = new Package("a/a", "1.0", "1.0");
  486. $a->setIncludePaths(array("lib/"));
  487. $packages[] = $a;
  488. $this->repository->expects($this->once())
  489. ->method("getCanonicalPackages")
  490. ->will($this->returnValue($packages));
  491. mkdir($this->vendorDir."/composer", 0777, true);
  492. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_11');
  493. $oldIncludePath = get_include_path();
  494. require $this->vendorDir."/autoload.php";
  495. $this->assertEquals(
  496. $this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath,
  497. get_include_path()
  498. );
  499. set_include_path($oldIncludePath);
  500. }
  501. public function testIncludePathsInMainPackage()
  502. {
  503. $package = new Package('a', '1.0', '1.0');
  504. $package->setIncludePaths(array('/lib', '/src'));
  505. $packages = array($a = new Package("a/a", "1.0", "1.0"));
  506. $a->setIncludePaths(array("lib/"));
  507. $this->repository->expects($this->once())
  508. ->method("getCanonicalPackages")
  509. ->will($this->returnValue($packages));
  510. mkdir($this->vendorDir."/composer", 0777, true);
  511. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12');
  512. $oldIncludePath = get_include_path();
  513. require $this->vendorDir."/autoload.php";
  514. $this->assertEquals(
  515. $this->workingDir."/lib".PATH_SEPARATOR.$this->workingDir."/src".PATH_SEPARATOR.$this->vendorDir."/a/a/lib".PATH_SEPARATOR.$oldIncludePath,
  516. get_include_path()
  517. );
  518. set_include_path($oldIncludePath);
  519. }
  520. public function testIncludePathFileWithoutPathsIsSkipped()
  521. {
  522. $package = new Package('a', '1.0', '1.0');
  523. $packages = array();
  524. $a = new Package("a/a", "1.0", "1.0");
  525. $packages[] = $a;
  526. $this->repository->expects($this->once())
  527. ->method("getCanonicalPackages")
  528. ->will($this->returnValue($packages));
  529. mkdir($this->vendorDir."/composer", 0777, true);
  530. $this->generator->dump($this->config, $this->repository, $package, $this->im, "composer", false, '_12');
  531. $this->assertFalse(file_exists($this->vendorDir."/composer/include_paths.php"));
  532. }
  533. public function testPreAndPostEventsAreDispatchedDuringAutoloadDump()
  534. {
  535. $this->eventDispatcher
  536. ->expects($this->at(0))
  537. ->method('dispatchScript')
  538. ->with(ScriptEvents::PRE_AUTOLOAD_DUMP, false);
  539. $this->eventDispatcher
  540. ->expects($this->at(1))
  541. ->method('dispatchScript')
  542. ->with(ScriptEvents::POST_AUTOLOAD_DUMP, false);
  543. $package = new Package('a', '1.0', '1.0');
  544. $package->setAutoload(array('psr-0' => array('foo/bar/non/existing/')));
  545. $this->repository->expects($this->once())
  546. ->method('getCanonicalPackages')
  547. ->will($this->returnValue(array()));
  548. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_8');
  549. }
  550. public function testUseGlobalIncludePath()
  551. {
  552. $package = new Package('a', '1.0', '1.0');
  553. $package->setAutoload(array(
  554. 'psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => ''),
  555. ));
  556. $package->setTargetDir('Main/Foo/');
  557. $this->repository->expects($this->once())
  558. ->method('getCanonicalPackages')
  559. ->will($this->returnValue(array()));
  560. $this->config->expects($this->at(2))
  561. ->method('get')
  562. ->with($this->equalTo('use-include-path'))
  563. ->will($this->returnValue(true));
  564. $this->fs->ensureDirectoryExists($this->vendorDir.'/a');
  565. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'IncludePath');
  566. $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_include_path.php', $this->vendorDir.'/composer/autoload_real.php');
  567. }
  568. public function testVendorDirExcludedFromWorkingDir()
  569. {
  570. $workingDir = $this->vendorDir.'/working-dir';
  571. $vendorDir = $workingDir.'/../vendor';
  572. $this->fs->ensureDirectoryExists($workingDir);
  573. chdir($workingDir);
  574. $package = new Package('a', '1.0', '1.0');
  575. $package->setAutoload(array(
  576. 'psr-0' => array('Foo' => 'src'),
  577. 'psr-4' => array('Acme\Foo\\' => 'src-psr4'),
  578. 'classmap' => array('classmap'),
  579. 'files' => array('test.php'),
  580. ));
  581. $vendorPackage = new Package('b/b', '1.0', '1.0');
  582. $vendorPackage->setAutoload(array(
  583. 'psr-0' => array('Bar' => 'lib'),
  584. 'psr-4' => array('Acme\Bar\\' => 'lib-psr4'),
  585. 'classmap' => array('classmaps'),
  586. 'files' => array('bootstrap.php'),
  587. ));
  588. $this->repository->expects($this->once())
  589. ->method('getCanonicalPackages')
  590. ->will($this->returnValue(array($vendorPackage)));
  591. $im = $this->getMockBuilder('Composer\Installer\InstallationManager')
  592. ->disableOriginalConstructor()
  593. ->getMock();
  594. $im->expects($this->any())
  595. ->method('getInstallPath')
  596. ->will($this->returnCallback(function ($package) use ($vendorDir) {
  597. $targetDir = $package->getTargetDir();
  598. return $vendorDir.'/'.$package->getName() . ($targetDir ? '/'.$targetDir : '');
  599. }));
  600. $this->fs->ensureDirectoryExists($workingDir.'/src/Foo');
  601. $this->fs->ensureDirectoryExists($workingDir.'/classmap');
  602. $this->fs->ensureDirectoryExists($vendorDir.'/composer');
  603. $this->fs->ensureDirectoryExists($vendorDir.'/b/b/lib/Bar');
  604. $this->fs->ensureDirectoryExists($vendorDir.'/b/b/classmaps');
  605. file_put_contents($workingDir.'/src/Foo/Bar.php', '<?php namespace Foo; class Bar {}');
  606. file_put_contents($workingDir.'/classmap/classes.php', '<?php namespace Foo; class Foo {}');
  607. file_put_contents($workingDir.'/test.php', '<?php class Foo {}');
  608. file_put_contents($vendorDir.'/b/b/lib/Bar/Foo.php', '<?php namespace Bar; class Foo {}');
  609. file_put_contents($vendorDir.'/b/b/classmaps/classes.php', '<?php namespace Bar; class Bar {}');
  610. file_put_contents($vendorDir.'/b/b/bootstrap.php', '<?php class Bar {}');
  611. $oldVendorDir = $this->vendorDir;
  612. $this->vendorDir = $vendorDir;
  613. $this->generator->dump($this->config, $this->repository, $package, $im, 'composer', true, '_13');
  614. $this->vendorDir = $oldVendorDir;
  615. $expectedNamespace = <<<'EOF'
  616. <?php
  617. // autoload_namespaces.php @generated by Composer
  618. $vendorDir = dirname(dirname(__FILE__));
  619. $baseDir = dirname($vendorDir).'/working-dir';
  620. return array(
  621. 'Foo' => array($baseDir . '/src'),
  622. 'Bar' => array($vendorDir . '/b/b/lib'),
  623. );
  624. EOF;
  625. $expectedPsr4 = <<<'EOF'
  626. <?php
  627. // autoload_psr4.php @generated by Composer
  628. $vendorDir = dirname(dirname(__FILE__));
  629. $baseDir = dirname($vendorDir).'/working-dir';
  630. return array(
  631. 'Acme\\Foo\\' => array($baseDir . '/src-psr4'),
  632. 'Acme\\Bar\\' => array($vendorDir . '/b/b/lib-psr4'),
  633. );
  634. EOF;
  635. $expectedClassmap = <<<'EOF'
  636. <?php
  637. // autoload_classmap.php @generated by Composer
  638. $vendorDir = dirname(dirname(__FILE__));
  639. $baseDir = dirname($vendorDir).'/working-dir';
  640. return array(
  641. 'Bar\\Bar' => $vendorDir . '/b/b/classmaps/classes.php',
  642. 'Bar\\Foo' => $vendorDir . '/b/b/lib/Bar/Foo.php',
  643. 'Foo\\Bar' => $baseDir . '/src/Foo/Bar.php',
  644. 'Foo\\Foo' => $baseDir . '/classmap/classes.php',
  645. );
  646. EOF;
  647. $this->assertEquals($expectedNamespace, file_get_contents($vendorDir.'/composer/autoload_namespaces.php'));
  648. $this->assertEquals($expectedPsr4, file_get_contents($vendorDir.'/composer/autoload_psr4.php'));
  649. $this->assertEquals($expectedClassmap, file_get_contents($vendorDir.'/composer/autoload_classmap.php'));
  650. $this->assertContains("\n \$vendorDir . '/b/b/bootstrap.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
  651. $this->assertContains("\n \$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
  652. }
  653. public function testUpLevelRelativePaths()
  654. {
  655. $workingDir = $this->workingDir.'/working-dir';
  656. mkdir($workingDir, 0777, true);
  657. chdir($workingDir);
  658. $package = new Package('a', '1.0', '1.0');
  659. $package->setAutoload(array(
  660. 'psr-0' => array('Foo' => '../path/../src'),
  661. 'psr-4' => array('Acme\Foo\\' => '../path/../src-psr4'),
  662. 'classmap' => array('../classmap'),
  663. 'files' => array('../test.php'),
  664. ));
  665. $this->repository->expects($this->once())
  666. ->method('getCanonicalPackages')
  667. ->will($this->returnValue(array()));
  668. $this->fs->ensureDirectoryExists($this->workingDir.'/src/Foo');
  669. $this->fs->ensureDirectoryExists($this->workingDir.'/classmap');
  670. file_put_contents($this->workingDir.'/src/Foo/Bar.php', '<?php namespace Foo; class Bar {}');
  671. file_put_contents($this->workingDir.'/classmap/classes.php', '<?php namespace Foo; class Foo {}');
  672. file_put_contents($this->workingDir.'/test.php', '<?php class Foo {}');
  673. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_14');
  674. $expectedNamespace = <<<'EOF'
  675. <?php
  676. // autoload_namespaces.php @generated by Composer
  677. $vendorDir = dirname(dirname(__FILE__));
  678. $baseDir = dirname($vendorDir).'/working-dir';
  679. return array(
  680. 'Foo' => array($baseDir . '/../src'),
  681. );
  682. EOF;
  683. $expectedPsr4 = <<<'EOF'
  684. <?php
  685. // autoload_psr4.php @generated by Composer
  686. $vendorDir = dirname(dirname(__FILE__));
  687. $baseDir = dirname($vendorDir).'/working-dir';
  688. return array(
  689. 'Acme\\Foo\\' => array($baseDir . '/../src-psr4'),
  690. );
  691. EOF;
  692. $expectedClassmap = <<<'EOF'
  693. <?php
  694. // autoload_classmap.php @generated by Composer
  695. $vendorDir = dirname(dirname(__FILE__));
  696. $baseDir = dirname($vendorDir).'/working-dir';
  697. return array(
  698. 'Foo\\Bar' => $baseDir . '/../src/Foo/Bar.php',
  699. 'Foo\\Foo' => $baseDir . '/../classmap/classes.php',
  700. );
  701. EOF;
  702. $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
  703. $this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir.'/composer/autoload_psr4.php'));
  704. $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
  705. $this->assertContains("\n \$baseDir . '/../test.php',\n", file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
  706. }
  707. public function testEmptyPaths()
  708. {
  709. $package = new Package('a', '1.0', '1.0');
  710. $package->setAutoload(array(
  711. 'psr-0' => array('Foo' => ''),
  712. 'psr-4' => array('Acme\Foo\\' => ''),
  713. 'classmap' => array(''),
  714. ));
  715. $this->repository->expects($this->once())
  716. ->method('getCanonicalPackages')
  717. ->will($this->returnValue(array()));
  718. $this->fs->ensureDirectoryExists($this->workingDir.'/Foo');
  719. file_put_contents($this->workingDir.'/Foo/Bar.php', '<?php namespace Foo; class Bar {}');
  720. file_put_contents($this->workingDir.'/class.php', '<?php namespace Classmap; class Foo {}');
  721. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_15');
  722. $expectedNamespace = <<<'EOF'
  723. <?php
  724. // autoload_namespaces.php @generated by Composer
  725. $vendorDir = dirname(dirname(__FILE__));
  726. $baseDir = dirname($vendorDir);
  727. return array(
  728. 'Foo' => array($baseDir . '/'),
  729. );
  730. EOF;
  731. $expectedPsr4 = <<<'EOF'
  732. <?php
  733. // autoload_psr4.php @generated by Composer
  734. $vendorDir = dirname(dirname(__FILE__));
  735. $baseDir = dirname($vendorDir);
  736. return array(
  737. 'Acme\\Foo\\' => array($baseDir . '/'),
  738. );
  739. EOF;
  740. $expectedClassmap = <<<'EOF'
  741. <?php
  742. // autoload_classmap.php @generated by Composer
  743. $vendorDir = dirname(dirname(__FILE__));
  744. $baseDir = dirname($vendorDir);
  745. return array(
  746. 'Classmap\\Foo' => $baseDir . '/class.php',
  747. 'Foo\\Bar' => $baseDir . '/Foo/Bar.php',
  748. );
  749. EOF;
  750. $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
  751. $this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir.'/composer/autoload_psr4.php'));
  752. $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir.'/composer/autoload_classmap.php'));
  753. }
  754. public function testVendorSubstringPath()
  755. {
  756. $package = new Package('a', '1.0', '1.0');
  757. $package->setAutoload(array(
  758. 'psr-0' => array('Foo' => 'composer-test-autoload-src/src'),
  759. 'psr-4' => array('Acme\Foo\\' => 'composer-test-autoload-src/src-psr4'),
  760. ));
  761. $this->repository->expects($this->once())
  762. ->method('getCanonicalPackages')
  763. ->will($this->returnValue(array()));
  764. $this->fs->ensureDirectoryExists($this->vendorDir.'/a');
  765. $expectedNamespace = <<<'EOF'
  766. <?php
  767. // autoload_namespaces.php @generated by Composer
  768. $vendorDir = dirname(dirname(__FILE__));
  769. $baseDir = dirname($vendorDir);
  770. return array(
  771. 'Foo' => array($baseDir . '/composer-test-autoload-src/src'),
  772. );
  773. EOF;
  774. $expectedPsr4 = <<<'EOF'
  775. <?php
  776. // autoload_psr4.php @generated by Composer
  777. $vendorDir = dirname(dirname(__FILE__));
  778. $baseDir = dirname($vendorDir);
  779. return array(
  780. 'Acme\\Foo\\' => array($baseDir . '/composer-test-autoload-src/src-psr4'),
  781. );
  782. EOF;
  783. $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'VendorSubstring');
  784. $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir.'/composer/autoload_namespaces.php'));
  785. $this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir.'/composer/autoload_psr4.php'));
  786. }
  787. private function assertAutoloadFiles($name, $dir, $type = 'namespaces')
  788. {
  789. $a = __DIR__.'/Fixtures/autoload_'.$name.'.php';
  790. $b = $dir.'/autoload_'.$type.'.php';
  791. $this->assertFileEquals($a, $b);
  792. }
  793. }