Skip to content

Commit

Permalink
ETPKIM-1062 fix bug in FileSystemPHPUnitTestCase::__construct
Browse files Browse the repository at this point in the history
  • Loading branch information
ptash committed Jan 14, 2017
1 parent 5876caf commit fc6d4b1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
7 changes: 6 additions & 1 deletion tests/FileSystemPHPUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ class FileSystemPHPUnitTestCase extends \PHPUnit_Framework_TestCase
/**
* ReleaseCheckerTest constructor.
*
* @param string $name See @see PHPUnit_Framework_TestCase.
* @param array $data See @see PHPUnit_Framework_TestCase.
* @param string $dataName See @see PHPUnit_Framework_TestCase.
*
* @return void
*/
public function __construct()
public function __construct($name = null, array $data = array(), $dataName = '')
{
$this->fileSystem = new FileSystem();
$this->dirTmp = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fileSystemTmp';
parent::__construct($name, $data, $dataName);
}

/**
Expand Down
47 changes: 31 additions & 16 deletions tests/FileSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,46 @@ public function testEmptyDirectory()
/**
* Testing normalizePath.
*
* @param string $dirSeparator Separator.
* @param string $checkValues Check values as array('somePath' => 'normalizePath').
*
* @return void
*
* @dataProvider getProviderTestCreateLinkToJSDirs
*/
public function testNormalizePath()
public function testNormalizePath($dirSeparator, $checkValues)
{
$fileSystem = new FileSystem();
$fileSystem->setDirectorySeparator('/');
$checkVals = array(
'C:\rrr' => 'C:/rrr',
'/fff/..\\ddd' => '/ddd',
'http://dddd\\dddd/rrr.gif' => 'http://dddd/dddd/rrr.gif'
);
foreach ($checkVals as $key => $val) {
$fileSystem->setDirectorySeparator($dirSeparator);
foreach ($checkValues as $key => $val) {
$res = $fileSystem->normalizePath($key);
$this->assertEquals($res, $val);
}
}

$fileSystem->setDirectorySeparator('\\');
$checkVals = array(
'C:\rrr' => 'C:\\rrr',
'/fff/../.\\ddd' => '\\ddd'
/**
* Data provider for testCreateLinkToJSDirs test.
* @return array
*/
public function getProviderTestCreateLinkToJSDirs()
{
return array(
array(
'/',
array(
'C:\rrr' => 'C:/rrr',
'/fff/..\\ddd' => '/ddd',
'http://dddd\\dddd/rrr.gif' => 'http://dddd/dddd/rrr.gif'
)
),
array(
'\\',
array(
'C:\rrr' => 'C:\\rrr',
'/fff/../.\\ddd' => '\\ddd'
)
)
);
foreach ($checkVals as $key => $val) {
$res = $fileSystem->normalizePath($key);
$this->assertEquals($res, $val);
}
}

/**
Expand Down

0 comments on commit fc6d4b1

Please sign in to comment.