From 2a9d856d1a0d657d3888b41065cddd10332aa887 Mon Sep 17 00:00:00 2001 From: mageekguy Date: Fri, 15 Jun 2012 13:04:01 +0200 Subject: [PATCH] Related to issue #49 again. --- classes/scripts/phar/generator.php | 2 +- .../iterators/recursives/atoum/source.php | 2 +- .../report/fields/runner/coverage/html.php | 23 +++++++++++-------- .../fields/runner/tests/uncompleted/cli.php | 4 ++-- .../units/classes/scripts/builder/vcs/svn.php | 21 ++++++++++------- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/classes/scripts/phar/generator.php b/classes/scripts/phar/generator.php index 8b229a13d..62a58621d 100644 --- a/classes/scripts/phar/generator.php +++ b/classes/scripts/phar/generator.php @@ -205,7 +205,7 @@ protected function cleanPath($path) { $path = ''; } - else if (DIRECTORY_SEPARATOR == '/' && $path != '/') + else if (DIRECTORY_SEPARATOR != '/' || $path != '/') { $path = rtrim($path, DIRECTORY_SEPARATOR); } diff --git a/tests/units/classes/iterators/recursives/atoum/source.php b/tests/units/classes/iterators/recursives/atoum/source.php index 45684b1e4..46e9dbf0a 100644 --- a/tests/units/classes/iterators/recursives/atoum/source.php +++ b/tests/units/classes/iterators/recursives/atoum/source.php @@ -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')) diff --git a/tests/units/classes/report/fields/runner/coverage/html.php b/tests/units/classes/report/fields/runner/coverage/html.php index fba6efcf5..601ba608b 100644 --- a/tests/units/classes/report/fields/runner/coverage/html.php +++ b/tests/units/classes/report/fields/runner/coverage/html.php @@ -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) @@ -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)); + } } ?> diff --git a/tests/units/classes/report/fields/runner/tests/uncompleted/cli.php b/tests/units/classes/report/fields/runner/tests/uncompleted/cli.php index 4fdbd3aea..42052ca85 100644 --- a/tests/units/classes/report/fields/runner/tests/uncompleted/cli.php +++ b/tests/units/classes/report/fields/runner/tests/uncompleted/cli.php @@ -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 @@ -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 . '"' . diff --git a/tests/units/classes/scripts/builder/vcs/svn.php b/tests/units/classes/scripts/builder/vcs/svn.php index 99e4e09fa..a8c8b2b8b 100644 --- a/tests/units/classes/scripts/builder/vcs/svn.php +++ b/tests/units/classes/scripts/builder/vcs/svn.php @@ -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)); + } } ?>