diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-10-15 13:43:04 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-10-20 15:09:43 +0200 |
commit | 8f8abdbaeef7bcaff1f822714a7f227933cc43c1 (patch) | |
tree | d7f4debad1aee9156b384dc07ce8ac410def21bd /tests/lib/templatelayout.php | |
parent | 7b94c7f9c1d2dd8115506d90f04f9e3e2f989cf5 (diff) | |
download | nextcloud-server-8f8abdbaeef7bcaff1f822714a7f227933cc43c1.tar.gz nextcloud-server-8f8abdbaeef7bcaff1f822714a7f227933cc43c1.zip |
Add unit tests for convertToRelativePath
Diffstat (limited to 'tests/lib/templatelayout.php')
-rw-r--r-- | tests/lib/templatelayout.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/lib/templatelayout.php b/tests/lib/templatelayout.php new file mode 100644 index 00000000000..f87db4fa54b --- /dev/null +++ b/tests/lib/templatelayout.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Test; + +/** + * @package OC\Test + */ +class OC_TemplateLayout extends \PHPUnit_Framework_TestCase { + + /** + * Contains valid file paths in the scheme array($absolutePath, $expectedPath) + * @return array + */ + public function validFilePathProvider() { + return array( + array(\OC::$SERVERROOT . '/apps/files/js/fancyJS.js', '/apps/files/js/fancyJS.js'), + array(\OC::$SERVERROOT. '/test.js', '/test.js'), + array(\OC::$SERVERROOT . '/core/test.js', '/core/test.js'), + array(\OC::$SERVERROOT, ''), + ); + } + + /** + * @dataProvider validFilePathProvider + */ + public function testConvertToRelativePath($absolutePath, $expected) { + $relativePath = \Test_Helper::invokePrivate(new \OC_TemplateLayout('user'), 'convertToRelativePath', array($absolutePath)); + $this->assertEquals($expected, $relativePath); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage $filePath is not under the \OC::$SERVERROOT + */ + public function testInvalidConvertToRelativePath() { + \Test_Helper::invokePrivate(new \OC_TemplateLayout('user'), 'convertToRelativePath', array('/this/file/is/invalid')); + } +} |