Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/samsonos/php_fs_local
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyiegorov committed Nov 24, 2014
2 parents e929fcc + 357594b commit bb4d327
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/LocalFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ public function delete($filename)
{
unlink($filename);
}

/**
* Get file extension in current file system
* @param $filePath string Path
* @return string|bool false if extension not found, otherwise file extension
*/
public function extension($filePath)
{
return pathinfo($filePath, PATHINFO_EXTENSION);
}
}
13 changes: 13 additions & 0 deletions tests/MainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,17 @@ public function testMoveToExisting()
// Perform test
$this->assertEquals(false, $newPath, 'File service move failed - Moved file not found');
}

/** Test file service extension method */
public function testExtension()
{
// Get instance using services factory as error will signal other way
$this->fileService = \samson\core\Service::getInstance('samson\fs\LocalFileService');

// Move file to a new dir
$extension = $this->fileService->extension(__FILE__);

// Perform test
$this->assertEquals('php', $extension, 'File service extension method failed - Extension is not correct');
}
}

0 comments on commit bb4d327

Please sign in to comment.