Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix up commenting and formatting.
  • Loading branch information
markstory committed Mar 30, 2018
1 parent e081c01 commit 4323074
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Filesystem/File.php
Expand Up @@ -363,7 +363,7 @@ public function name()
*/ */
protected static function _basename($path, $ext = null) protected static function _basename($path, $ext = null)
{ {
//check for multibyte string and use basename() if not found // check for multibyte string and use basename() if not found
if (mb_strlen($path) === strlen($path)) { if (mb_strlen($path) === strlen($path)) {
return ($ext === null)? basename($path) : basename($path, $ext); return ($ext === null)? basename($path) : basename($path, $ext);
} }
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/Filesystem/FileTest.php
Expand Up @@ -140,6 +140,7 @@ public function testUtf8Filenames()


/** /**
* Test _basename method * Test _basename method
*
* @dataProvider baseNameValueProvider * @dataProvider baseNameValueProvider
* @return void * @return void
*/ */
Expand All @@ -150,22 +151,21 @@ public function testBasename($path, $suffix, $isRoot)
} }
$File = new File($path, false); $File = new File($path, false);


//some of paths is directory like '/etc/sudoers.d' // some paths are directories like '/etc/sudoers.d'
if (!is_dir($path)) { if (!is_dir($path)) {
//test the name after running __construct() // Check the name after running __construct()
$result = $File->name; $result = $File->name;
$expecting = basename($path); $expecting = basename($path);
$this->assertEquals($expecting, $result); $this->assertEquals($expecting, $result);
} }


//test the name() // Check name()
$splInfo = new SplFileInfo($path); $splInfo = new SplFileInfo($path);
$File->name = ltrim($splInfo->getFilename(), '/\\'); $File->name = ltrim($splInfo->getFilename(), '/\\');
if ($suffix === null) { if ($suffix === null) {
$File->info();//to set and unset 'extension' in bellow $File->info();//to set and unset 'extension' in bellow
if (isset($File->info['extension'])) { unset($File->info['extension']);
unset($File->info['extension']);
}
$this->assertEquals(basename($path), $File->name()); $this->assertEquals(basename($path), $File->name());
} else { } else {
$File->info['extension'] = $suffix; $File->info['extension'] = $suffix;
Expand Down

0 comments on commit 4323074

Please sign in to comment.