1
0
Fork 0

Fixed tests for autoloader generator

pull/1696/head
Martin Hasoň 2013-03-14 10:23:35 +01:00
parent 48444a028c
commit 3499610631
8 changed files with 30 additions and 48 deletions

View File

@ -261,12 +261,12 @@ class AutoloadGeneratorTest extends TestCase
$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->assertEquals(
$this->normalizePaths(array(
array(
'ClassMapBar' => $this->vendorDir.'/b/b/src/b.php',
'ClassMapBaz' => $this->vendorDir.'/b/b/lib/c.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');
}
@ -297,12 +297,12 @@ class AutoloadGeneratorTest extends TestCase
$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->assertEquals(
$this->normalizePaths(array(
array(
'ClassMapBar' => $this->vendorDir.'/a/a/target/lib/b.php',
'ClassMapBaz' => $this->vendorDir.'/b/b/src/c.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->assertTrue(file_exists($this->vendorDir.'/composer/autoload_classmap.php'), "ClassMap file needs to be generated.");
$this->assertEquals(
$this->normalizePaths(array(
array(
'ClassMapBar' => $this->vendorDir.'/b/b/test.php',
'ClassMapBaz' => $this->vendorDir.'/c/c/foo/test.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');
}
@ -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/classmap/classes.php', '<?php namespace Foo; class Bar {}');
$workDir = strtr($this->workingDir, '\\', '/');
$expectedNamespace = <<<EOF
<?php
@ -479,9 +478,9 @@ class AutoloadGeneratorTest extends TestCase
\$baseDir = dirname(\$vendorDir);
return array(
'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src/',
'A\\\\B' => array('$workDir/lib', \$vendorDir . '/a/a/lib/'),
'A' => \$vendorDir . '/a/a/src/',
'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src',
'A\\\\B' => array(\$baseDir . '/lib', \$vendorDir . '/a/a/lib'),
'A' => \$vendorDir . '/a/a/src',
);
EOF;
@ -755,23 +754,6 @@ EOF;
{
$a = __DIR__.'/Fixtures/autoload_'.$name.'.php';
$b = $dir.'/autoload_'.$type.'.php';
$this->assertEquals(
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;
$this->assertFileEquals($a, $b);
}
}

View File

@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = $vendorDir;
return array(
'ClassMapFoo' => $baseDir . '/composersrc/foo.php',
'Main\\Foo' => $baseDir . '/src/Main/Foo.php',
'ClassMapFoo' => $vendorDir . '/composersrc/foo.php',
'Main\\Foo' => $vendorDir . '/src/Main/Foo.php',
);

View File

@ -6,7 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ClassMapBar' => $baseDir . '/%vendorDir%/b/b/src/b.php',
'ClassMapBaz' => $baseDir . '/%vendorDir%/b/b/lib/c.php',
'ClassMapFoo' => $baseDir . '/%vendorDir%/a/a/src/a.php',
'ClassMapBar' => $vendorDir . '/b/b/src/b.php',
'ClassMapBaz' => $vendorDir . '/b/b/lib/c.php',
'ClassMapFoo' => $vendorDir . '/a/a/src/a.php',
);

View File

@ -6,7 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ClassMapBar' => $baseDir . '/%vendorDir%/b/b/test.php',
'ClassMapBaz' => $baseDir . '/%vendorDir%/c/c/foo/test.php',
'ClassMapFoo' => $baseDir . '/%vendorDir%/a/a/src/a.php',
'ClassMapBar' => $vendorDir . '/b/b/test.php',
'ClassMapBaz' => $vendorDir . '/c/c/foo/test.php',
'ClassMapFoo' => $vendorDir . '/a/a/src/a.php',
);

View File

@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Main' => $baseDir . '/src/',
'Lala' => array($baseDir . '/src/', $baseDir . '/lib/'),
'Main' => $baseDir . '/src',
'Lala' => array($baseDir . '/src', $baseDir . '/lib'),
);

View File

@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir));
return array(
'Main' => $baseDir . '/src/',
'Lala' => $baseDir . '/src/',
'Main' => $baseDir . '/src',
'Lala' => $baseDir . '/src',
);

View File

@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = $vendorDir;
return array(
'Main' => $baseDir . '/src/',
'Lala' => $baseDir . '/src/',
'Main' => $baseDir . '/src',
'Lala' => $baseDir . '/src',
);

View File

@ -6,7 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'B\\Sub\\Name' => $vendorDir . '/b/b/src/',
'A\\B' => $vendorDir . '/a/a/lib/',
'A' => $vendorDir . '/a/a/src/',
'B\\Sub\\Name' => $vendorDir . '/b/b/src',
'A\\B' => $vendorDir . '/a/a/lib',
'A' => $vendorDir . '/a/a/src',
);