From adc4aee80f7cd3242f65f0b316af2b560a64712c Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Wed, 7 Dec 2016 11:58:25 +0100 Subject: Change templates set through administration UI --- tests/ApplicationUtilsTest.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 861b8d4e..634bd0ed 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -289,6 +289,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase $conf->set('resource.page_cache', 'pagecache'); $conf->set('resource.raintpl_tmp', 'tmp'); $conf->set('resource.raintpl_tpl', 'tpl'); + $conf->set('resource.theme', 'default'); $conf->set('resource.update_check', 'data/lastupdatecheck.txt'); $this->assertEquals( @@ -312,10 +313,12 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase $conf->set('resource.page_cache', 'null/pagecache'); $conf->set('resource.raintpl_tmp', 'null/tmp'); $conf->set('resource.raintpl_tpl', 'null/tpl'); + $conf->set('resource.raintpl_theme', 'null/tpl/default'); $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt'); $this->assertEquals( array( '"null/tpl" directory is not readable', + '"null/tpl/default" directory is not readable', '"null/cache" directory is not readable', '"null/cache" directory is not writable', '"null/data" directory is not readable', -- cgit v1.2.3 From a0df06517bada0f811b464017ce385290e02c2bf Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 3 Jan 2017 11:42:21 +0100 Subject: Minor improvements regarding #705 (coding style, unit tests, etc.) --- tests/ApplicationUtilsTest.php | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 634bd0ed..c39649e8 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -331,4 +331,48 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase ApplicationUtils::checkResourcePermissions($conf) ); } + + /** + * Test getThemes() with existing theme directories. + */ + public function testGetThemes() + { + $themes = ['theme1', 'default', 'Bl1p_- bL0p']; + foreach ($themes as $theme) { + mkdir('sandbox/tpl/'. $theme, 0777, true); + } + + // include a file which should be ignored + touch('sandbox/tpl/supertheme'); + + $res = ApplicationUtils::getThemes('sandbox/tpl/'); + foreach ($res as $theme) { + $this->assertTrue(in_array($theme, $themes)); + } + $this->assertFalse(in_array('supertheme', $res)); + + foreach ($themes as $theme) { + rmdir('sandbox/tpl/'. $theme); + } + unlink('sandbox/tpl/supertheme'); + rmdir('sandbox/tpl'); + } + + /** + * Test getThemes() without any theme dir. + */ + public function testGetThemesEmpty() + { + mkdir('sandbox/tpl/', 0777, true); + $this->assertEquals([], ApplicationUtils::getThemes('sandbox/tpl/')); + rmdir('sandbox/tpl/'); + } + + /** + * Test getThemes() with an invalid path. + */ + public function testGetThemesInvalid() + { + $this->assertEquals([], ApplicationUtils::getThemes('nope')); + } } -- cgit v1.2.3 From 04a0e8ea34c241fdf6bd30b11f5242656f9cd1c2 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 3 Jan 2017 12:01:25 +0100 Subject: Updater: keep custom theme preference with the new theme setting --- tests/ApplicationUtilsTest.php | 44 ------------------------------------------ 1 file changed, 44 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index c39649e8..634bd0ed 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -331,48 +331,4 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase ApplicationUtils::checkResourcePermissions($conf) ); } - - /** - * Test getThemes() with existing theme directories. - */ - public function testGetThemes() - { - $themes = ['theme1', 'default', 'Bl1p_- bL0p']; - foreach ($themes as $theme) { - mkdir('sandbox/tpl/'. $theme, 0777, true); - } - - // include a file which should be ignored - touch('sandbox/tpl/supertheme'); - - $res = ApplicationUtils::getThemes('sandbox/tpl/'); - foreach ($res as $theme) { - $this->assertTrue(in_array($theme, $themes)); - } - $this->assertFalse(in_array('supertheme', $res)); - - foreach ($themes as $theme) { - rmdir('sandbox/tpl/'. $theme); - } - unlink('sandbox/tpl/supertheme'); - rmdir('sandbox/tpl'); - } - - /** - * Test getThemes() without any theme dir. - */ - public function testGetThemesEmpty() - { - mkdir('sandbox/tpl/', 0777, true); - $this->assertEquals([], ApplicationUtils::getThemes('sandbox/tpl/')); - rmdir('sandbox/tpl/'); - } - - /** - * Test getThemes() with an invalid path. - */ - public function testGetThemesInvalid() - { - $this->assertEquals([], ApplicationUtils::getThemes('nope')); - } } -- cgit v1.2.3 From 3c66e56435359dc678048193e8ee239d06f79b64 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Fri, 3 Mar 2017 23:06:12 +0100 Subject: application: introduce the Shaarli\Config namespace Namespaces have been introduced with the REST API, and should be generalized to the whole codebase to manage object scope and benefit from autoloading. See: - https://secure.php.net/manual/en/language.namespaces.php - http://www.php-fig.org/psr/psr-4/ Signed-off-by: VirtualTam --- tests/ApplicationUtilsTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 634bd0ed..ad86e21c 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -1,9 +1,10 @@ Date: Sun, 12 Mar 2017 15:02:06 +0100 Subject: Use 'dev' version on the master branch Allowed check branches are now `latest` and `stable`. --- tests/ApplicationUtilsTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index ad86e21c..ef4f46a8 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -332,4 +332,15 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase ApplicationUtils::checkResourcePermissions($conf) ); } + + /** + * Check update with 'dev' as curent version (master branch). + * It should always return false. + */ + public function testCheckUpdateDev() + { + $this->assertFalse( + ApplicationUtils::checkUpdate('dev', self::$testUpdateFile, 100, true, true) + ); + } } -- cgit v1.2.3 From b786c8836f0576d4feb1543471950c5d24bc7939 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 21 Mar 2017 20:08:40 +0100 Subject: Set Shaarli's version only in shaarli_version.php file --- tests/ApplicationUtilsTest.php | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index ef4f46a8..ebdc365c 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -17,7 +17,7 @@ class FakeApplicationUtils extends ApplicationUtils /** * Toggle HTTP requests, allow overriding the version code */ - public static function getLatestGitVersionCode($url, $timeout=0) + public static function getVersion($url, $timeout=0) { return self::$VERSION_CODE; } @@ -44,18 +44,28 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase } } + /** + * Remove test version file if it exists + */ + public function tearDown() + { + if (is_file('sandbox/version.php')) { + unlink('sandbox/version.php'); + } + } + /** * Retrieve the latest version code available on Git * * Expected format: Semantic Versioning - major.minor.patch */ - public function testGetLatestGitVersionCode() + public function testGetVersionCode() { $testTimeout = 10; $this->assertEquals( '0.5.4', - ApplicationUtils::getLatestGitVersionCode( + ApplicationUtils::getVersion( 'https://raw.githubusercontent.com/shaarli/Shaarli/' .'v0.5.4/shaarli_version.php', $testTimeout @@ -63,7 +73,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase ); $this->assertRegExp( self::$versionPattern, - ApplicationUtils::getLatestGitVersionCode( + ApplicationUtils::getVersion( 'https://raw.githubusercontent.com/shaarli/Shaarli/' .'master/shaarli_version.php', $testTimeout @@ -72,14 +82,26 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase } /** - * Attempt to retrieve the latest version from an invalid URL + * Attempt to retrieve the latest version from an invalid File + */ + public function testGetVersionCodeFromFile() + { + file_put_contents('sandbox/version.php', ''. PHP_EOL); + $this->assertEquals( + '1.2.3', + ApplicationUtils::getVersion('sandbox/version.php', 1) + ); + } + + /** + * Attempt to retrieve the latest version from an invalid File */ - public function testGetLatestGitVersionCodeInvalidUrl() + public function testGetVersionCodeInvalidFile() { $oldlog = ini_get('error_log'); ini_set('error_log', '/dev/null'); $this->assertFalse( - ApplicationUtils::getLatestGitVersionCode('htttp://null.io', 1) + ApplicationUtils::getVersion('idontexist', 1) ); ini_set('error_log', $oldlog); } -- cgit v1.2.3 From 5e4a83bb98718a10cda24d1a75645ac0fe3a8dab Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 22 Mar 2017 18:55:09 +0100 Subject: Fix version check branch for UT --- tests/ApplicationUtilsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index ebdc365c..ff4c9e17 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -75,7 +75,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase self::$versionPattern, ApplicationUtils::getVersion( 'https://raw.githubusercontent.com/shaarli/Shaarli/' - .'master/shaarli_version.php', + .'latest/shaarli_version.php', $testTimeout ) ); -- cgit v1.2.3