Fixed tests for autoloader generator
parent
48444a028c
commit
3499610631
|
@ -261,12 +261,12 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
|
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
|
||||||
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->normalizePaths(array(
|
array(
|
||||||
'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php',
|
'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php',
|
||||||
'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.php',
|
'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.php',
|
||||||
'ClassMapFoo' => $this->vendorDir.'/a/a/src/a.php',
|
'ClassMapFoo' => $this->vendorDir.'/a/a/src/a.php',
|
||||||
)),
|
),
|
||||||
$this->normalizePaths(include $this->vendorDir.'/composer/autoload_classmap.php')
|
include $this->vendorDir.'/composer/autoload_classmap.php'
|
||||||
);
|
);
|
||||||
$this->assertAutoloadFiles('classmap4', $this->vendorDir.'/composer', 'classmap');
|
$this->assertAutoloadFiles('classmap4', $this->vendorDir.'/composer', 'classmap');
|
||||||
}
|
}
|
||||||
|
@ -297,12 +297,12 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
|
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_6');
|
||||||
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->normalizePaths(array(
|
array(
|
||||||
'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php',
|
'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php',
|
||||||
'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.php',
|
'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.php',
|
||||||
'ClassMapFoo' => $this->vendorDir.'/a/a/target/src/a.php',
|
'ClassMapFoo' => $this->vendorDir.'/a/a/target/src/a.php',
|
||||||
)),
|
),
|
||||||
$this->normalizePaths(include $this->vendorDir.'/composer/autoload_classmap.php')
|
include $this->vendorDir.'/composer/autoload_classmap.php'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,12 +333,12 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7');
|
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7');
|
||||||
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
$this->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->normalizePaths(array(
|
array(
|
||||||
'ClassMapBar' => $this->vendorDir.'/b/b/test.php',
|
'ClassMapBar' => $this->vendorDir.'/b/b/test.php',
|
||||||
'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.php',
|
'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.php',
|
||||||
'ClassMapFoo' => $this->vendorDir.'/a/a/src/a.php',
|
'ClassMapFoo' => $this->vendorDir.'/a/a/src/a.php',
|
||||||
)),
|
),
|
||||||
$this->normalizePaths(include $this->vendorDir.'/composer/autoload_classmap.php')
|
include $this->vendorDir.'/composer/autoload_classmap.php'
|
||||||
);
|
);
|
||||||
$this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap');
|
$this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap');
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,6 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
file_put_contents($this->vendorDir.'/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
|
file_put_contents($this->vendorDir.'/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
|
||||||
file_put_contents($this->vendorDir.'/a/a/classmap/classes.php', '<?php namespace Foo; class Bar {}');
|
file_put_contents($this->vendorDir.'/a/a/classmap/classes.php', '<?php namespace Foo; class Bar {}');
|
||||||
|
|
||||||
$workDir = strtr($this->workingDir, '\\', '/');
|
|
||||||
$expectedNamespace = <<<EOF
|
$expectedNamespace = <<<EOF
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@ -479,9 +478,9 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
\$baseDir = dirname(\$vendorDir);
|
\$baseDir = dirname(\$vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src/',
|
'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src',
|
||||||
'A\\\\B' => array('$workDir/lib', \$vendorDir . '/a/a/lib/'),
|
'A\\\\B' => array(\$baseDir . '/lib', \$vendorDir . '/a/a/lib'),
|
||||||
'A' => \$vendorDir . '/a/a/src/',
|
'A' => \$vendorDir . '/a/a/src',
|
||||||
);
|
);
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
@ -755,23 +754,6 @@ EOF;
|
||||||
{
|
{
|
||||||
$a = __DIR__.'/Fixtures/autoload_'.$name.'.php';
|
$a = __DIR__.'/Fixtures/autoload_'.$name.'.php';
|
||||||
$b = $dir.'/autoload_'.$type.'.php';
|
$b = $dir.'/autoload_'.$type.'.php';
|
||||||
$this->assertEquals(
|
$this->assertFileEquals($a, $b);
|
||||||
str_replace('%vendorDir%', basename($this->vendorDir), file_get_contents($a)),
|
|
||||||
file_get_contents($b),
|
|
||||||
$a .' does not equal '. $b
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function normalizePaths($paths)
|
|
||||||
{
|
|
||||||
if (!is_array($paths)) {
|
|
||||||
return strtr($paths, '\\', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($paths as $key => $path) {
|
|
||||||
$paths[$key] = strtr($path, '\\', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $paths;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = $vendorDir;
|
$baseDir = $vendorDir;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'ClassMapFoo' => $baseDir . '/composersrc/foo.php',
|
'ClassMapFoo' => $vendorDir . '/composersrc/foo.php',
|
||||||
'Main\\Foo' => $baseDir . '/src/Main/Foo.php',
|
'Main\\Foo' => $vendorDir . '/src/Main/Foo.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'ClassMapBar' => $baseDir . '/%vendorDir%/b/b/src/b.php',
|
'ClassMapBar' => $vendorDir . '/b/b/src/b.php',
|
||||||
'ClassMapBaz' => $baseDir . '/%vendorDir%/b/b/lib/c.php',
|
'ClassMapBaz' => $vendorDir . '/b/b/lib/c.php',
|
||||||
'ClassMapFoo' => $baseDir . '/%vendorDir%/a/a/src/a.php',
|
'ClassMapFoo' => $vendorDir . '/a/a/src/a.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'ClassMapBar' => $baseDir . '/%vendorDir%/b/b/test.php',
|
'ClassMapBar' => $vendorDir . '/b/b/test.php',
|
||||||
'ClassMapBaz' => $baseDir . '/%vendorDir%/c/c/foo/test.php',
|
'ClassMapBaz' => $vendorDir . '/c/c/foo/test.php',
|
||||||
'ClassMapFoo' => $baseDir . '/%vendorDir%/a/a/src/a.php',
|
'ClassMapFoo' => $vendorDir . '/a/a/src/a.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Main' => $baseDir . '/src/',
|
'Main' => $baseDir . '/src',
|
||||||
'Lala' => array($baseDir . '/src/', $baseDir . '/lib/'),
|
'Lala' => array($baseDir . '/src', $baseDir . '/lib'),
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname(dirname($vendorDir));
|
$baseDir = dirname(dirname($vendorDir));
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Main' => $baseDir . '/src/',
|
'Main' => $baseDir . '/src',
|
||||||
'Lala' => $baseDir . '/src/',
|
'Lala' => $baseDir . '/src',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = $vendorDir;
|
$baseDir = $vendorDir;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Main' => $baseDir . '/src/',
|
'Main' => $baseDir . '/src',
|
||||||
'Lala' => $baseDir . '/src/',
|
'Lala' => $baseDir . '/src',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||||
$baseDir = dirname($vendorDir);
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'B\\Sub\\Name' => $vendorDir . '/b/b/src/',
|
'B\\Sub\\Name' => $vendorDir . '/b/b/src',
|
||||||
'A\\B' => $vendorDir . '/a/a/lib/',
|
'A\\B' => $vendorDir . '/a/a/lib',
|
||||||
'A' => $vendorDir . '/a/a/src/',
|
'A' => $vendorDir . '/a/a/src',
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue