Skip to content

Commit

Permalink
Related to issue #49 again.
Browse files Browse the repository at this point in the history
  • Loading branch information
mageekguy committed Jun 15, 2012
1 parent a2d9dfe commit 2a9d856
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion classes/scripts/phar/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected function cleanPath($path)
{
$path = '';
}
else if (DIRECTORY_SEPARATOR == '/' && $path != '/')
else if (DIRECTORY_SEPARATOR != '/' || $path != '/')
{
$path = rtrim($path, DIRECTORY_SEPARATOR);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/units/classes/iterators/recursives/atoum/source.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testCurrent()
->and($sourceDirectoryController->readdir[2] = false)
->and($iterator = new iterators\recursives\atoum\source($sourceDirectory = 'atoum://sourceDirectory'))
->then
->string($iterator->current())->isEqualTo('atoum://sourceDirectory/file')
->string($iterator->current())->isEqualTo('atoum://sourceDirectory' . DIRECTORY_SEPARATOR . 'file')
->if($sourceDirectoryController->readdir[1] = '.file')
->and($sourceDirectoryController->readdir[2] = false)
->and($iterator = new iterators\recursives\atoum\source($sourceDirectory = 'atoum://sourceDirectory'))
Expand Down
23 changes: 14 additions & 9 deletions tests/units/classes/report/fields/runner/coverage/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ public function testCleanDestinationDirectory()
->then
->object($field->cleanDestinationDirectory())->isIdenticalTo($field)
->adapter($adapter)
->call('unlink')->withArguments('atoum://destinationDirectory/aDirectory/firstFile')->once()
->call('unlink')->withArguments('atoum://destinationDirectory/aDirectory/secondFile')->once()
->call('rmdir')->withArguments('atoum://destinationDirectory/aDirectory')->once()
->call('unlink')->withArguments('atoum://destinationDirectory/anOtherDirectory/anOtherFirstFile')->once()
->call('unlink')->withArguments('atoum://destinationDirectory/anOtherDirectory/anOtherSecondFile')->once()
->call('rmdir')->withArguments('atoum://destinationDirectory/anOtherDirectory')->once()
->call('unlink')->withArguments('atoum://destinationDirectory/aFile')->once()
->call('rmdir')->withArguments('atoum://destinationDirectory/emptyDirectory')->once()
->call('rmdir')->withArguments($destinationDirectoryPath)->never()
->call('unlink')->withArguments(self::cleanPath('atoum://destinationDirectory/aDirectory/firstFile'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://destinationDirectory/aDirectory/secondFile'))->once()
->call('rmdir')->withArguments(self::cleanPath('atoum://destinationDirectory/aDirectory'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://destinationDirectory/anOtherDirectory/anOtherFirstFile'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://destinationDirectory/anOtherDirectory/anOtherSecondFile'))->once()
->call('rmdir')->withArguments(self::cleanPath('atoum://destinationDirectory/anOtherDirectory'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://destinationDirectory/aFile'))->once()
->call('rmdir')->withArguments(self::cleanPath('atoum://destinationDirectory/emptyDirectory'))->once()
->call('rmdir')->withArguments(self::cleanPath($destinationDirectoryPath))->never()
->if($field->getMockController()->getDestinationDirectoryIterator->throw = new \exception())
->then
->object($field->cleanDestinationDirectory())->isIdenticalTo($field)
Expand Down Expand Up @@ -572,6 +572,11 @@ public function test__toString()
->castToString($field)->isIdenticalTo(sprintf($field->getLocale()->_('Code coverage: %3.2f%%.'), round($coverageValue * 100, 2)) . PHP_EOL . 'Unable to generate code coverage at ' . $rootUrl . '/: ' . $errorMessage . '.' . PHP_EOL)
;
}

protected static function cleanPath($path)
{
return (DIRECTORY_SEPARATOR == '/' ? $path : str_replace('/', '\\', $path));
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function test__toString()
sprintf('%s::%s() with exit code %d:', $class, $method, $exitCode) . PHP_EOL .
'output(' . strlen($output) . ') "' . $output . '"' . PHP_EOL .
sprintf('%s::%s() with exit code %d:', $otherClass, $otherMethod, $otherExitCode) . PHP_EOL .
'output(' . (strlen($otherOutputLine1) + strlen($otherOutputLine2) + 1) . ') "' . $otherOutputLine1 . PHP_EOL .
'output(' . (strlen($otherOutputLine1 . PHP_EOL . $otherOutputLine2)) . ') "' . $otherOutputLine1 . PHP_EOL .
$otherOutputLine2 . '"' . PHP_EOL .
sprintf('%s::%s() with exit code %d:', $anotherClass, $anotherMethod, $anotherExitCode) . PHP_EOL .
'output(0) ""' . PHP_EOL
Expand Down Expand Up @@ -269,7 +269,7 @@ public function test__toString()
) .
PHP_EOL .
$outputPrompt .
'output(' . (strlen($otherOutputLine1) + strlen($otherOutputLine2) + 1) . ') "' . $otherOutputLine1 .
'output(' . (strlen($otherOutputLine1 . PHP_EOL . $otherOutputLine2)) . ') "' . $otherOutputLine1 .
PHP_EOL .
$outputPrompt .
$otherOutputLine2 . '"' .
Expand Down
21 changes: 13 additions & 8 deletions tests/units/classes/scripts/builder/vcs/svn.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,22 @@ public function testCleanWorkingDirectory()
->when(function() use ($svn) { $svn->setWorkingDirectory('atoum://workingDirectory'); })
->object($svn->cleanWorkingDirectory())->isIdenticalTo($svn)
->adapter($adapter)
->call('unlink')->withArguments('atoum://workingDirectory/aDirectory/firstFile')->once()
->call('unlink')->withArguments('atoum://workingDirectory/aDirectory/secondFile')->once()
->call('rmdir')->withArguments('atoum://workingDirectory/aDirectory')->once()
->call('rmdir')->withArguments('atoum://workingDirectory/emptyDirectory')->once()
->call('unlink')->withArguments('atoum://workingDirectory/anOtherDirectory/anOtherFirstFile')->once()
->call('unlink')->withArguments('atoum://workingDirectory/anOtherDirectory/anOtherSecondFile')->once()
->call('rmdir')->withArguments('atoum://workingDirectory/anOtherDirectory')->once()
->call('unlink')->withArguments('atoum://workingDirectory/aFile')->once()
->call('unlink')->withArguments(self::cleanPath('atoum://workingDirectory/aDirectory/firstFile'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://workingDirectory/aDirectory/secondFile'))->once()
->call('rmdir')->withArguments(self::cleanPath('atoum://workingDirectory/aDirectory'))->once()
->call('rmdir')->withArguments(self::cleanPath('atoum://workingDirectory/emptyDirectory'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://workingDirectory/anOtherDirectory/anOtherFirstFile'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://workingDirectory/anOtherDirectory/anOtherSecondFile'))->once()
->call('rmdir')->withArguments(self::cleanPath('atoum://workingDirectory/anOtherDirectory'))->once()
->call('unlink')->withArguments(self::cleanPath('atoum://workingDirectory/aFile'))->once()
->call('rmdir')->withArguments('atoum://workingDirectory')->never()
;
}

protected static function cleanPath($path)
{
return (DIRECTORY_SEPARATOR == '/' ? $path : str_replace('/', '\\', $path));
}
}

?>

0 comments on commit 2a9d856

Please sign in to comment.