From 684e662a58b02bde225e44d3677987b6fc3adf0b Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 18 May 2016 21:48:24 +0200 Subject: Replace $GLOBALS configuration with the configuration manager in the whole code base --- tests/ApplicationUtilsTest.php | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 6064357d..cf82b655 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -3,6 +3,7 @@ * ApplicationUtils' tests */ +require_once 'application/config/ConfigManager.php'; require_once 'application/ApplicationUtils.php'; /** @@ -59,7 +60,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase $testTimeout ) ); - $this->assertRegexp( + $this->assertRegExp( self::$versionPattern, ApplicationUtils::getLatestGitVersionCode( 'https://raw.githubusercontent.com/shaarli/Shaarli/' @@ -275,21 +276,21 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase */ public function testCheckCurrentResourcePermissions() { - $config = array( - 'CACHEDIR' => 'cache', - 'CONFIG_FILE' => 'data/config.php', - 'DATADIR' => 'data', - 'DATASTORE' => 'data/datastore.php', - 'IPBANS_FILENAME' => 'data/ipbans.php', - 'LOG_FILE' => 'data/log.txt', - 'PAGECACHE' => 'pagecache', - 'RAINTPL_TMP' => 'tmp', - 'RAINTPL_TPL' => 'tpl', - 'UPDATECHECK_FILENAME' => 'data/lastupdatecheck.txt' - ); + $conf = ConfigManager::getInstance(); + $conf->set('config.CACHEDIR', 'cache'); + $conf->set('config.CONFIG_FILE', 'data/config.php'); + $conf->set('config.DATADIR', 'data'); + $conf->set('config.DATASTORE', 'data/datastore.php'); + $conf->set('config.IPBANS_FILENAME', 'data/ipbans.php'); + $conf->set('config.LOG_FILE', 'data/log.txt'); + $conf->set('config.PAGECACHE', 'pagecache'); + $conf->set('config.RAINTPL_TMP', 'tmp'); + $conf->set('config.RAINTPL_TPL', 'tpl'); + $conf->set('config.UPDATECHECK_FILENAME', 'data/lastupdatecheck.txt'); + $this->assertEquals( array(), - ApplicationUtils::checkResourcePermissions($config) + ApplicationUtils::checkResourcePermissions() ); } @@ -298,18 +299,17 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase */ public function testCheckCurrentResourcePermissionsErrors() { - $config = array( - 'CACHEDIR' => 'null/cache', - 'CONFIG_FILE' => 'null/data/config.php', - 'DATADIR' => 'null/data', - 'DATASTORE' => 'null/data/store.php', - 'IPBANS_FILENAME' => 'null/data/ipbans.php', - 'LOG_FILE' => 'null/data/log.txt', - 'PAGECACHE' => 'null/pagecache', - 'RAINTPL_TMP' => 'null/tmp', - 'RAINTPL_TPL' => 'null/tpl', - 'UPDATECHECK_FILENAME' => 'null/data/lastupdatecheck.txt' - ); + $conf = ConfigManager::getInstance(); + $conf->set('config.CACHEDIR', 'null/cache'); + $conf->set('config.CONFIG_FILE', 'null/data/config.php'); + $conf->set('config.DATADIR', 'null/data'); + $conf->set('config.DATASTORE', 'null/data/store.php'); + $conf->set('config.IPBANS_FILENAME', 'null/data/ipbans.php'); + $conf->set('config.LOG_FILE', 'null/data/log.txt'); + $conf->set('config.PAGECACHE', 'null/pagecache'); + $conf->set('config.RAINTPL_TMP', 'null/tmp'); + $conf->set('config.RAINTPL_TPL', 'null/tpl'); + $conf->set('config.UPDATECHECK_FILENAME', 'null/data/lastupdatecheck.txt'); $this->assertEquals( array( '"null/tpl" directory is not readable', @@ -322,7 +322,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase '"null/tmp" directory is not readable', '"null/tmp" directory is not writable' ), - ApplicationUtils::checkResourcePermissions($config) + ApplicationUtils::checkResourcePermissions() ); } } -- cgit v1.2.3 From da10377b3c263d96a46cf9101c202554343d2cd0 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 29 May 2016 16:10:32 +0200 Subject: Rename configuration keys and fix GLOBALS in templates --- tests/ApplicationUtilsTest.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index cf82b655..f92412ba 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -277,16 +277,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase public function testCheckCurrentResourcePermissions() { $conf = ConfigManager::getInstance(); - $conf->set('config.CACHEDIR', 'cache'); - $conf->set('config.CONFIG_FILE', 'data/config.php'); - $conf->set('config.DATADIR', 'data'); - $conf->set('config.DATASTORE', 'data/datastore.php'); - $conf->set('config.IPBANS_FILENAME', 'data/ipbans.php'); - $conf->set('config.LOG_FILE', 'data/log.txt'); - $conf->set('config.PAGECACHE', 'pagecache'); - $conf->set('config.RAINTPL_TMP', 'tmp'); - $conf->set('config.RAINTPL_TPL', 'tpl'); - $conf->set('config.UPDATECHECK_FILENAME', 'data/lastupdatecheck.txt'); + $conf->set('path.thumbnails_cache', 'cache'); + $conf->set('path.config', 'data/config.php'); + $conf->set('path.data_dir', 'data'); + $conf->set('path.datastore', 'data/datastore.php'); + $conf->set('path.ban_file', 'data/ipbans.php'); + $conf->set('path.log', 'data/log.txt'); + $conf->set('path.page_cache', 'pagecache'); + $conf->set('path.raintpl_tmp', 'tmp'); + $conf->set('path.raintpl_tpl', 'tpl'); + $conf->set('path.update_check', 'data/lastupdatecheck.txt'); $this->assertEquals( array(), @@ -300,16 +300,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase public function testCheckCurrentResourcePermissionsErrors() { $conf = ConfigManager::getInstance(); - $conf->set('config.CACHEDIR', 'null/cache'); - $conf->set('config.CONFIG_FILE', 'null/data/config.php'); - $conf->set('config.DATADIR', 'null/data'); - $conf->set('config.DATASTORE', 'null/data/store.php'); - $conf->set('config.IPBANS_FILENAME', 'null/data/ipbans.php'); - $conf->set('config.LOG_FILE', 'null/data/log.txt'); - $conf->set('config.PAGECACHE', 'null/pagecache'); - $conf->set('config.RAINTPL_TMP', 'null/tmp'); - $conf->set('config.RAINTPL_TPL', 'null/tpl'); - $conf->set('config.UPDATECHECK_FILENAME', 'null/data/lastupdatecheck.txt'); + $conf->set('path.thumbnails_cache', 'null/cache'); + $conf->set('path.config', 'null/data/config.php'); + $conf->set('path.data_dir', 'null/data'); + $conf->set('path.datastore', 'null/data/store.php'); + $conf->set('path.ban_file', 'null/data/ipbans.php'); + $conf->set('path.log', 'null/data/log.txt'); + $conf->set('path.page_cache', 'null/pagecache'); + $conf->set('path.raintpl_tmp', 'null/tmp'); + $conf->set('path.raintpl_tpl', 'null/tpl'); + $conf->set('path.update_check', 'null/data/lastupdatecheck.txt'); $this->assertEquals( array( '"null/tpl" directory is not readable', -- cgit v1.2.3 From 278d9ee2836df7d805845077f26f8cecd16f0f4f Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 9 Jun 2016 20:04:02 +0200 Subject: ConfigManager no longer uses singleton pattern --- tests/ApplicationUtilsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index f92412ba..3da72639 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -276,7 +276,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase */ public function testCheckCurrentResourcePermissions() { - $conf = ConfigManager::getInstance(); + $conf = new ConfigManager(''); $conf->set('path.thumbnails_cache', 'cache'); $conf->set('path.config', 'data/config.php'); $conf->set('path.data_dir', 'data'); @@ -290,7 +290,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase $this->assertEquals( array(), - ApplicationUtils::checkResourcePermissions() + ApplicationUtils::checkResourcePermissions($conf) ); } @@ -299,7 +299,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase */ public function testCheckCurrentResourcePermissionsErrors() { - $conf = ConfigManager::getInstance(); + $conf = new ConfigManager(''); $conf->set('path.thumbnails_cache', 'null/cache'); $conf->set('path.config', 'null/data/config.php'); $conf->set('path.data_dir', 'null/data'); @@ -322,7 +322,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase '"null/tmp" directory is not readable', '"null/tmp" directory is not writable' ), - ApplicationUtils::checkResourcePermissions() + ApplicationUtils::checkResourcePermissions($conf) ); } } -- cgit v1.2.3 From 894a3c4bf38d8dcadb6941049b9167e5101805bd Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 11 Jun 2016 09:08:02 +0200 Subject: Rename configuration key for better sections --- tests/ApplicationUtilsTest.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'tests/ApplicationUtilsTest.php') diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php index 3da72639..c37a94f0 100644 --- a/tests/ApplicationUtilsTest.php +++ b/tests/ApplicationUtilsTest.php @@ -277,16 +277,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase public function testCheckCurrentResourcePermissions() { $conf = new ConfigManager(''); - $conf->set('path.thumbnails_cache', 'cache'); - $conf->set('path.config', 'data/config.php'); - $conf->set('path.data_dir', 'data'); - $conf->set('path.datastore', 'data/datastore.php'); - $conf->set('path.ban_file', 'data/ipbans.php'); - $conf->set('path.log', 'data/log.txt'); - $conf->set('path.page_cache', 'pagecache'); - $conf->set('path.raintpl_tmp', 'tmp'); - $conf->set('path.raintpl_tpl', 'tpl'); - $conf->set('path.update_check', 'data/lastupdatecheck.txt'); + $conf->set('resource.thumbnails_cache', 'cache'); + $conf->set('resource.config', 'data/config.php'); + $conf->set('resource.data_dir', 'data'); + $conf->set('resource.datastore', 'data/datastore.php'); + $conf->set('resource.ban_file', 'data/ipbans.php'); + $conf->set('resource.log', 'data/log.txt'); + $conf->set('resource.page_cache', 'pagecache'); + $conf->set('resource.raintpl_tmp', 'tmp'); + $conf->set('resource.raintpl_tpl', 'tpl'); + $conf->set('resource.update_check', 'data/lastupdatecheck.txt'); $this->assertEquals( array(), @@ -300,16 +300,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase public function testCheckCurrentResourcePermissionsErrors() { $conf = new ConfigManager(''); - $conf->set('path.thumbnails_cache', 'null/cache'); - $conf->set('path.config', 'null/data/config.php'); - $conf->set('path.data_dir', 'null/data'); - $conf->set('path.datastore', 'null/data/store.php'); - $conf->set('path.ban_file', 'null/data/ipbans.php'); - $conf->set('path.log', 'null/data/log.txt'); - $conf->set('path.page_cache', 'null/pagecache'); - $conf->set('path.raintpl_tmp', 'null/tmp'); - $conf->set('path.raintpl_tpl', 'null/tpl'); - $conf->set('path.update_check', 'null/data/lastupdatecheck.txt'); + $conf->set('resource.thumbnails_cache', 'null/cache'); + $conf->set('resource.config', 'null/data/config.php'); + $conf->set('resource.data_dir', 'null/data'); + $conf->set('resource.datastore', 'null/data/store.php'); + $conf->set('resource.ban_file', 'null/data/ipbans.php'); + $conf->set('resource.log', 'null/data/log.txt'); + $conf->set('resource.page_cache', 'null/pagecache'); + $conf->set('resource.raintpl_tmp', 'null/tmp'); + $conf->set('resource.raintpl_tpl', 'null/tpl'); + $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt'); $this->assertEquals( array( '"null/tpl" directory is not readable', -- cgit v1.2.3