diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-07-29 23:32:03 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-07-29 23:32:03 +0200 |
commit | 085fdfec2f298fd89d0265d0f97edfdda5a12954 (patch) | |
tree | a5004ab03dfcec7fedf3acb009365517f72cf4ce /tests | |
parent | e2d3225e5aff343bf62b6dbb62eb3526e525cb6b (diff) | |
download | nextcloud-server-085fdfec2f298fd89d0265d0f97edfdda5a12954.tar.gz nextcloud-server-085fdfec2f298fd89d0265d0f97edfdda5a12954.zip |
adding unit tests for OC_Util::basename
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/util.php | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/tests/lib/util.php b/tests/lib/util.php index 9742d57ac7a..2781ade0990 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -8,12 +8,9 @@ class Test_Util extends PHPUnit_Framework_TestCase { - // Constructor - function Test_Util() { + function testFormatDate() { date_default_timezone_set("UTC"); - } - function testFormatDate() { $result = OC_Util::formatDate(1350129205); $expected = 'October 13, 2012 11:53'; $this->assertEquals($expected, $result); @@ -61,8 +58,27 @@ class Test_Util extends PHPUnit_Framework_TestCase { OC_Config::deleteKey('mail_domain'); } - function testGetInstanceIdGeneratesValidId() { - OC_Config::deleteKey('instanceid'); - $this->assertStringStartsWith('oc', OC_Util::getInstanceId()); - } + function testGetInstanceIdGeneratesValidId() { + OC_Config::deleteKey('instanceid'); + $this->assertStringStartsWith('oc', OC_Util::getInstanceId()); + } + + /** + * @dataProvider baseNameProvider + */ + public function testBaseName($expected, $file) + { + $base = \OC_Util::basename($file); + $this->assertEquals($expected, $base); + } + + public function baseNameProvider() + { + return array( + array('public_html', '/home/user/public_html/'), + array('public_html', '/home/user/public_html'), + array('', '/'), + array('442aa682de2a64db1e010f50e60fd9c9', 'local::C:\Users\ADMINI~1\AppData\Local\Temp\2/442aa682de2a64db1e010f50e60fd9c9/') + ); + } } |