Skip to content

Commit

Permalink
Change "PHP" to "php" for Travis. Add a few tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mermshaus committed Mar 25, 2016
1 parent e12d414 commit 00b539e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ sudo: false

matrix:
include:
- PHP: 5.3
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
Expand Down
16 changes: 14 additions & 2 deletions src/PathHelper.php
Expand Up @@ -11,8 +11,17 @@

use InvalidArgumentException;

/**
*
*/
final class PathHelper
{
/**
*
* @param string $path
* @return string
* @throws InvalidArgumentException
*/
public function normalizeDirectorySeparators($path)
{
if (!is_string($path)) {
Expand All @@ -21,8 +30,11 @@ public function normalizeDirectorySeparators($path)

$directorySeparatorInverse = (DIRECTORY_SEPARATOR === '/') ? '\\' : '/';

return str_replace($directorySeparatorInverse, DIRECTORY_SEPARATOR,
$path);
return str_replace(
$directorySeparatorInverse,
DIRECTORY_SEPARATOR,
$path
);
}

/**
Expand Down
33 changes: 32 additions & 1 deletion tests/Kaloa/Tests/Filesystem/PathHelperTest.php
Expand Up @@ -12,8 +12,14 @@
use Kaloa\Filesystem\PathHelper;
use PHPUnit_Framework_TestCase;

/**
*
*/
class PathHelperTest extends PHPUnit_Framework_TestCase
{
/**
*
*/
public function testNormalize()
{
$ph = new PathHelper();
Expand Down Expand Up @@ -66,7 +72,10 @@ public function testNormalize()
$this->assertEquals('/', $f(' \\.\\dir1\\.\\dir2\\\\\\..\\..\\..\\\\\\ '));
}

public function testNormalize_Additional()
/**
*
*/
public function testNormalizeAdditional()
{
$ph = new PathHelper();

Expand All @@ -76,4 +85,26 @@ public function testNormalize_Additional()

$this->assertEquals('dir1', $f($f('./dir1/.//') . '/' . $f('dir2/../dir3//dir4/.././/..')));
}

/**
*
*/
public function testNormalizeThrowsException()
{
$this->setExpectedException('InvalidArgumentException');

$ph = new PathHelper();
$ph->normalize(42);
}

/**
*
*/
public function testNormalizeDirectorySeparatorsThrowsException()
{
$this->setExpectedException('InvalidArgumentException');

$ph = new PathHelper();
$ph->normalizeDirectorySeparators(42);
}
}

0 comments on commit 00b539e

Please sign in to comment.