mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Refactor & fix coding standard
This commit is contained in:
@@ -1032,6 +1032,8 @@ class Miscellaneous
|
|||||||
$separator = DIRECTORY_SEPARATOR;
|
$separator = DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
|
$path = trim($path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Empty paths are useless
|
* Empty paths are useless
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -503,16 +503,35 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
self::assertEquals('lorem ipsum', Miscellaneous::trimSmart(' lorem ipsum '));
|
self::assertEquals('lorem ipsum', Miscellaneous::trimSmart(' lorem ipsum '));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConcatenatePaths()
|
/**
|
||||||
|
* @param mixed $emptyPaths Empty paths co concatenate
|
||||||
|
* @dataProvider provideEmptyValue
|
||||||
|
*/
|
||||||
|
public function testConcatenatePathsWithEmptyPaths($emptyPaths)
|
||||||
|
{
|
||||||
|
self::assertEquals('', Miscellaneous::concatenatePaths($emptyPaths));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testConcatenatePathsWithOneEmptyPath()
|
||||||
|
{
|
||||||
|
$paths = [
|
||||||
|
'first/directory',
|
||||||
|
'second/one',
|
||||||
|
'',
|
||||||
|
'and/the/third',
|
||||||
|
];
|
||||||
|
|
||||||
|
$concatenated = Miscellaneous::concatenatePaths($paths);
|
||||||
|
unset($paths[2]);
|
||||||
|
$imploded = implode('/', $paths);
|
||||||
|
|
||||||
|
self::assertEquals('/' . $imploded, $concatenated);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testConcatenatePathsInNixOs()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Common cases
|
* For *nix operating system
|
||||||
*/
|
|
||||||
self::assertEquals('', Miscellaneous::concatenatePaths(null));
|
|
||||||
self::assertEquals('', Miscellaneous::concatenatePaths([]));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* *nix operating system
|
|
||||||
*/
|
*/
|
||||||
$paths1 = [
|
$paths1 = [
|
||||||
'first/directory',
|
'first/directory',
|
||||||
@@ -522,7 +541,10 @@ class MiscellaneousTest extends BaseTestCase
|
|||||||
|
|
||||||
self::assertEquals('/' . implode('/', $paths1), Miscellaneous::concatenatePaths($paths1));
|
self::assertEquals('/' . implode('/', $paths1), Miscellaneous::concatenatePaths($paths1));
|
||||||
self::assertEquals('/' . implode('/', $paths1), Miscellaneous::concatenatePaths($paths1[0], $paths1[1], $paths1[2]));
|
self::assertEquals('/' . implode('/', $paths1), Miscellaneous::concatenatePaths($paths1[0], $paths1[1], $paths1[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testConcatenatePathsInWindowsOs()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* For Windows operating system
|
* For Windows operating system
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user