From: ArthurHoaro Date: Wed, 8 Mar 2017 19:28:33 +0000 (+0100) Subject: Move config exception to dedicated classes with proper namespace X-Git-Tag: v0.9.0~43^2 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=5ba55f0cf287c583019bbb731ad98e04a14da972 Move config exception to dedicated classes with proper namespace --- diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index 679a75b3..f2097410 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -1,6 +1,9 @@ configIO = $configIO; } } - -/** - * Exception used if a mandatory field is missing in given configuration. - */ -class MissingFieldConfigException extends \Exception -{ - public $field; - - /** - * Construct exception. - * - * @param string $field field name missing. - */ - public function __construct($field) - { - $this->field = $field; - $this->message = 'Configuration value is required for '. $this->field; - } -} - -/** - * Exception used if an unauthorized attempt to edit configuration has been made. - */ -class UnauthorizedConfigException extends \Exception -{ - /** - * Construct exception. - */ - public function __construct() - { - $this->message = 'You are not authorized to alter config.'; - } -} diff --git a/application/config/exception/MissingFieldConfigException.php b/application/config/exception/MissingFieldConfigException.php new file mode 100644 index 00000000..6346c6a9 --- /dev/null +++ b/application/config/exception/MissingFieldConfigException.php @@ -0,0 +1,23 @@ +field = $field; + $this->message = 'Configuration value is required for '. $this->field; + } +} diff --git a/application/config/exception/UnauthorizedConfigException.php b/application/config/exception/UnauthorizedConfigException.php new file mode 100644 index 00000000..79672c1b --- /dev/null +++ b/application/config/exception/UnauthorizedConfigException.php @@ -0,0 +1,18 @@ +message = 'You are not authorized to alter config.'; + } +} diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php index b81be5b6..1ec447b2 100644 --- a/tests/config/ConfigManagerTest.php +++ b/tests/config/ConfigManagerTest.php @@ -106,7 +106,7 @@ class ConfigManagerTest extends \PHPUnit_Framework_TestCase /** * Try to write the config without mandatory parameter (e.g. 'login'). * - * @expectedException Shaarli\Config\MissingFieldConfigException + * @expectedException Shaarli\Config\Exception\MissingFieldConfigException */ public function testWriteMissingParameter() {