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 <virtualtam@flibidi.net>
This commit is contained in:
parent
74198dcdf6
commit
3c66e56435
26 changed files with 62 additions and 47 deletions
tests
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
/**
|
||||
* ApplicationUtils' tests
|
||||
*/
|
||||
|
||||
require_once 'application/config/ConfigManager.php';
|
||||
require_once 'application/ApplicationUtils.php';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
/**
|
||||
* Plugin Manager tests
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigJson;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Config\ConfigPhp;
|
||||
|
||||
require_once 'application/config/ConfigManager.php';
|
||||
require_once 'tests/Updater/DummyUpdater.php';
|
||||
require_once 'inc/rain.tpl.class.php';
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
|
@ -44,7 +45,7 @@ class ApiMiddlewareTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->conf = new \ConfigManager('tests/utils/config/configJson.json.php');
|
||||
$this->conf = new ConfigManager('tests/utils/config/configJson.json.php');
|
||||
$this->conf->set('api.secret', 'NapoleonWasALizard');
|
||||
|
||||
$this->refDB = new \ReferenceLinkDB();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
|
@ -25,7 +26,7 @@ class GetLinkIdTest extends \PHPUnit_Framework_TestCase
|
|||
protected static $testDatastore = 'sandbox/datastore.php';
|
||||
|
||||
/**
|
||||
* @var \ConfigManager instance
|
||||
* @var ConfigManager instance
|
||||
*/
|
||||
protected $conf;
|
||||
|
||||
|
@ -54,7 +55,7 @@ class GetLinkIdTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->conf = new \ConfigManager('tests/utils/config/configJson');
|
||||
$this->conf = new ConfigManager('tests/utils/config/configJson');
|
||||
$this->refDB = new \ReferenceLinkDB();
|
||||
$this->refDB->write(self::$testDatastore);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
|
@ -25,7 +25,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
|
|||
protected static $testDatastore = 'sandbox/datastore.php';
|
||||
|
||||
/**
|
||||
* @var \ConfigManager instance
|
||||
* @var ConfigManager instance
|
||||
*/
|
||||
protected $conf;
|
||||
|
||||
|
@ -54,7 +54,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->conf = new \ConfigManager('tests/utils/config/configJson');
|
||||
$this->conf = new ConfigManager('tests/utils/config/configJson');
|
||||
$this->refDB = new \ReferenceLinkDB();
|
||||
$this->refDB->write(self::$testDatastore);
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
|
@ -22,7 +23,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase
|
|||
protected static $testDatastore = 'sandbox/datastore.php';
|
||||
|
||||
/**
|
||||
* @var \ConfigManager instance
|
||||
* @var ConfigManager instance
|
||||
*/
|
||||
protected $conf;
|
||||
|
||||
|
@ -46,7 +47,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->conf = new \ConfigManager('tests/utils/config/configJson.json.php');
|
||||
$this->conf = new ConfigManager('tests/utils/config/configJson.json.php');
|
||||
$this->refDB = new \ReferenceLinkDB();
|
||||
$this->refDB->write(self::$testDatastore);
|
||||
|
||||
|
@ -84,7 +85,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('Shaarli', $data['settings']['title']);
|
||||
$this->assertEquals('?', $data['settings']['header_link']);
|
||||
$this->assertEquals('UTC', $data['settings']['timezone']);
|
||||
$this->assertEquals(\ConfigManager::$DEFAULT_PLUGINS, $data['settings']['enabled_plugins']);
|
||||
$this->assertEquals(ConfigManager::$DEFAULT_PLUGINS, $data['settings']['enabled_plugins']);
|
||||
$this->assertEquals(false, $data['settings']['default_private_links']);
|
||||
|
||||
$title = 'My links';
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once 'application/config/ConfigJson.php';
|
||||
namespace Shaarli\Config;
|
||||
|
||||
/**
|
||||
* Class ConfigJsonTest
|
||||
*/
|
||||
class ConfigJsonTest extends PHPUnit_Framework_TestCase
|
||||
class ConfigJsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConfigJson
|
||||
|
@ -40,7 +39,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Read a non existent config file -> empty array.
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage An error occurred while parsing JSON file: error code #4
|
||||
*/
|
||||
public function testReadInvalidJson()
|
||||
|
@ -112,7 +111,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Write to invalid path.
|
||||
*
|
||||
* @expectedException IOException
|
||||
* @expectedException \IOException
|
||||
*/
|
||||
public function testWriteInvalidArray()
|
||||
{
|
||||
|
@ -123,7 +122,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Write to invalid path.
|
||||
*
|
||||
* @expectedException IOException
|
||||
* @expectedException \IOException
|
||||
*/
|
||||
public function testWriteInvalidBlank()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Shaarli\Config;
|
||||
|
||||
/**
|
||||
* Unit tests for Class ConfigManagerTest
|
||||
|
@ -6,7 +7,7 @@
|
|||
* Note: it only test the manager with ConfigJson,
|
||||
* ConfigPhp is only a workaround to handle the transition to JSON type.
|
||||
*/
|
||||
class ConfigManagerTest extends PHPUnit_Framework_TestCase
|
||||
class ConfigManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConfigManager
|
||||
|
@ -83,7 +84,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Set with an empty key.
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
|
||||
*/
|
||||
public function testSetEmptyKey()
|
||||
|
@ -94,7 +95,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Set with an array key.
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
|
||||
*/
|
||||
public function testSetArrayKey()
|
||||
|
@ -105,7 +106,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Try to write the config without mandatory parameter (e.g. 'login').
|
||||
*
|
||||
* @expectedException MissingFieldConfigException
|
||||
* @expectedException Shaarli\Config\MissingFieldConfigException
|
||||
*/
|
||||
public function testWriteMissingParameter()
|
||||
{
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once 'application/config/ConfigPhp.php';
|
||||
namespace Shaarli\Config;
|
||||
|
||||
/**
|
||||
* Class ConfigPhpTest
|
||||
*/
|
||||
class ConfigPhpTest extends PHPUnit_Framework_TestCase
|
||||
class ConfigPhpTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConfigPhp
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
namespace Shaarli\Config;
|
||||
|
||||
/**
|
||||
* Config' tests
|
||||
*/
|
||||
|
@ -8,7 +10,7 @@ require_once 'application/config/ConfigPlugin.php';
|
|||
/**
|
||||
* Unitary tests for Shaarli config related functions
|
||||
*/
|
||||
class ConfigPluginTest extends PHPUnit_Framework_TestCase
|
||||
class ConfigPluginTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test save_plugin_config with valid data.
|
||||
|
@ -39,7 +41,7 @@ class ConfigPluginTest extends PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* Test save_plugin_config with invalid data.
|
||||
*
|
||||
* @expectedException PluginConfigOrderException
|
||||
* @expectedException Shaarli\Config\PluginConfigOrderException
|
||||
*/
|
||||
public function testSavePluginConfigInvalid()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
require_once 'plugins/isso/isso.php';
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
/**
|
||||
* PluginMarkdownTest.php
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
require_once 'plugins/pubsubhubbub/pubsubhubbub.php';
|
||||
require_once 'application/Router.php';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PluginQrcodeTest.php
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
/**
|
||||
* PluginReadityourselfTest.php.php
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
/**
|
||||
* PluginWallabagTest.php.php
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue