[Finder] Fixed tests on windows

This commit is contained in:
Jordi Boggiano 2010-11-17 23:42:21 +01:00 committed by Fabien Potencier
parent a0f933163f
commit b3ae62e2c4
5 changed files with 32 additions and 27 deletions

View File

@ -23,7 +23,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
{
parent::setUpBeforeClass();
self::$tmpDir = sys_get_temp_dir().'/symfony2_finder/';
self::$tmpDir = sys_get_temp_dir().'/symfony2_finder';
}
public function testDirectories()
@ -186,7 +186,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$finder = new Finder();
$iterator = $finder->files()->name('*.php')->depth('< 1')->in(array(self::$tmpDir, __DIR__))->getIterator();
$this->assertIterator(array(self::$tmpDir.'test.php', __DIR__.'/FinderTest.php', __DIR__.'/GlobTest.php'), $iterator);
$this->assertIterator(array(self::$tmpDir.DIRECTORY_SEPARATOR.'test.php', __DIR__.DIRECTORY_SEPARATOR.'FinderTest.php', __DIR__.DIRECTORY_SEPARATOR.'GlobTest.php'), $iterator);
}
public function testGetIterator()
@ -226,7 +226,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
{
$f = array();
foreach ($files as $file) {
$f[] = self::$tmpDir.$file;
$f[] = self::$tmpDir . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $file);
}
return $f;

View File

@ -23,7 +23,7 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
*/
public function testAccept($size, $expected)
{
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(sys_get_temp_dir().'/symfony2_finder', \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getAbsolutePath(''), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
$iterator = new DepthRangeFilterIterator($inner, $size);
@ -36,11 +36,16 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
public function getAcceptData()
{
return array(
array(array(new NumberComparator('< 1')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto')),
array(array(new NumberComparator('<= 1')), array(sys_get_temp_dir().'/symfony2_finder/.git', sys_get_temp_dir().'/symfony2_finder/test.py', sys_get_temp_dir().'/symfony2_finder/foo', sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', sys_get_temp_dir().'/symfony2_finder/test.php', sys_get_temp_dir().'/symfony2_finder/toto')),
array(array(new NumberComparator('< 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'))),
array(array(new NumberComparator('<= 1')), array($this->getAbsolutePath('/.git'), $this->getAbsolutePath('/test.py'), $this->getAbsolutePath('/foo'), $this->getAbsolutePath('/foo/bar.tmp'), $this->getAbsolutePath('/test.php'), $this->getAbsolutePath('/toto'))),
array(array(new NumberComparator('> 1')), array()),
array(array(new NumberComparator('>= 1')), array(sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp')),
array(array(new NumberComparator('1')), array(sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp')),
array(array(new NumberComparator('>= 1')), array($this->getAbsolutePath('/foo/bar.tmp'))),
array(array(new NumberComparator('1')), array($this->getAbsolutePath('/foo/bar.tmp'))),
);
}
protected function getAbsolutePath($path)
{
return sys_get_temp_dir().'/symfony2_finder'.str_replace('/', DIRECTORY_SEPARATOR, $path);
}
}

View File

@ -35,18 +35,18 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
return array(
array(array('foo'), array(
$tmpDir.'/.git',
$tmpDir.'/test.py',
$tmpDir.'/test.php',
$tmpDir.'/toto'
$tmpDir.DIRECTORY_SEPARATOR.'.git',
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
$tmpDir.DIRECTORY_SEPARATOR.'test.php',
$tmpDir.DIRECTORY_SEPARATOR.'toto'
)),
array(array('fo'), array(
$tmpDir.'/.git',
$tmpDir.'/test.py',
$tmpDir.'/foo',
$tmpDir.'/foo/bar.tmp',
$tmpDir.'/test.php',
$tmpDir.'/toto'
$tmpDir.DIRECTORY_SEPARATOR.'.git',
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
$tmpDir.DIRECTORY_SEPARATOR.'foo',
$tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
$tmpDir.DIRECTORY_SEPARATOR.'test.php',
$tmpDir.DIRECTORY_SEPARATOR.'toto'
)),
);
}

View File

@ -26,11 +26,11 @@ class IgnoreVcsFilterIteratorTest extends RealIteratorTestCase
$tmpDir = sys_get_temp_dir().'/symfony2_finder';
$this->assertIterator(array(
$tmpDir.'/test.py',
$tmpDir.'/foo',
$tmpDir.'/foo/bar.tmp',
$tmpDir.'/test.php',
$tmpDir.'/toto'
$tmpDir.DIRECTORY_SEPARATOR.'test.py',
$tmpDir.DIRECTORY_SEPARATOR.'foo',
$tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
$tmpDir.DIRECTORY_SEPARATOR.'test.php',
$tmpDir.DIRECTORY_SEPARATOR.'toto'
), $iterator);
}
}

View File

@ -31,9 +31,9 @@ class RealIteratorTestCase extends IteratorTestCase
if (is_dir($tmpDir)) {
self::tearDownAfterClass();
rmdir($tmpDir);
} else {
mkdir($tmpDir);
}
mkdir($tmpDir);
foreach (self::$files as $file) {
if ('/' === $file[strlen($file) - 1]) {
@ -46,8 +46,8 @@ class RealIteratorTestCase extends IteratorTestCase
file_put_contents($tmpDir.'/test.php', str_repeat(' ', 800));
file_put_contents($tmpDir.'/test.py', str_repeat(' ', 2000));
touch(sys_get_temp_dir().'/symfony2_finder/foo/bar.tmp', strtotime('2005-10-15'));
touch(sys_get_temp_dir().'/symfony2_finder/test.php', strtotime('2005-10-15'));
touch($tmpDir.'/foo/bar.tmp', strtotime('2005-10-15'));
touch($tmpDir.'/test.php', strtotime('2005-10-15'));
}
static public function tearDownAfterClass()