aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/config
diff options
context:
space:
mode:
Diffstat (limited to 'tests/config')
-rw-r--r--tests/config/ConfigJsonTest.php13
-rw-r--r--tests/config/ConfigManagerTest.php9
-rw-r--r--tests/config/ConfigPhpTest.php19
-rw-r--r--tests/config/ConfigPluginTest.php10
4 files changed, 32 insertions, 19 deletions
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index 07f6ab49..d237bc80 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -1,11 +1,10 @@
1<?php 1<?php
2 2namespace Shaarli\Config;
3require_once 'application/config/ConfigJson.php';
4 3
5/** 4/**
6 * Class ConfigJsonTest 5 * Class ConfigJsonTest
7 */ 6 */
8class ConfigJsonTest extends PHPUnit_Framework_TestCase 7class ConfigJsonTest extends \PHPUnit_Framework_TestCase
9{ 8{
10 /** 9 /**
11 * @var ConfigJson 10 * @var ConfigJson
@@ -40,8 +39,8 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
40 /** 39 /**
41 * Read a non existent config file -> empty array. 40 * Read a non existent config file -> empty array.
42 * 41 *
43 * @expectedException Exception 42 * @expectedException \Exception
44 * @expectedExceptionMessage An error occurred while parsing JSON file: error code #4 43 * @expectedExceptionMessageRegExp /An error occurred while parsing JSON configuration file \([\w\/\.]+\): error code #4/
45 */ 44 */
46 public function testReadInvalidJson() 45 public function testReadInvalidJson()
47 { 46 {
@@ -112,7 +111,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
112 /** 111 /**
113 * Write to invalid path. 112 * Write to invalid path.
114 * 113 *
115 * @expectedException IOException 114 * @expectedException \IOException
116 */ 115 */
117 public function testWriteInvalidArray() 116 public function testWriteInvalidArray()
118 { 117 {
@@ -123,7 +122,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
123 /** 122 /**
124 * Write to invalid path. 123 * Write to invalid path.
125 * 124 *
126 * @expectedException IOException 125 * @expectedException \IOException
127 */ 126 */
128 public function testWriteInvalidBlank() 127 public function testWriteInvalidBlank()
129 { 128 {
diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php
index 436e3d67..1ec447b2 100644
--- a/tests/config/ConfigManagerTest.php
+++ b/tests/config/ConfigManagerTest.php
@@ -1,4 +1,5 @@
1<?php 1<?php
2namespace Shaarli\Config;
2 3
3/** 4/**
4 * Unit tests for Class ConfigManagerTest 5 * Unit tests for Class ConfigManagerTest
@@ -6,7 +7,7 @@
6 * Note: it only test the manager with ConfigJson, 7 * Note: it only test the manager with ConfigJson,
7 * ConfigPhp is only a workaround to handle the transition to JSON type. 8 * ConfigPhp is only a workaround to handle the transition to JSON type.
8 */ 9 */
9class ConfigManagerTest extends PHPUnit_Framework_TestCase 10class ConfigManagerTest extends \PHPUnit_Framework_TestCase
10{ 11{
11 /** 12 /**
12 * @var ConfigManager 13 * @var ConfigManager
@@ -83,7 +84,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
83 /** 84 /**
84 * Set with an empty key. 85 * Set with an empty key.
85 * 86 *
86 * @expectedException Exception 87 * @expectedException \Exception
87 * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*# 88 * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
88 */ 89 */
89 public function testSetEmptyKey() 90 public function testSetEmptyKey()
@@ -94,7 +95,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
94 /** 95 /**
95 * Set with an array key. 96 * Set with an array key.
96 * 97 *
97 * @expectedException Exception 98 * @expectedException \Exception
98 * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*# 99 * @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
99 */ 100 */
100 public function testSetArrayKey() 101 public function testSetArrayKey()
@@ -105,7 +106,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
105 /** 106 /**
106 * Try to write the config without mandatory parameter (e.g. 'login'). 107 * Try to write the config without mandatory parameter (e.g. 'login').
107 * 108 *
108 * @expectedException MissingFieldConfigException 109 * @expectedException Shaarli\Config\Exception\MissingFieldConfigException
109 */ 110 */
110 public function testWriteMissingParameter() 111 public function testWriteMissingParameter()
111 { 112 {
diff --git a/tests/config/ConfigPhpTest.php b/tests/config/ConfigPhpTest.php
index 58cd8d2a..be23eea1 100644
--- a/tests/config/ConfigPhpTest.php
+++ b/tests/config/ConfigPhpTest.php
@@ -1,11 +1,10 @@
1<?php 1<?php
2 2namespace Shaarli\Config;
3require_once 'application/config/ConfigPhp.php';
4 3
5/** 4/**
6 * Class ConfigPhpTest 5 * Class ConfigPhpTest
7 */ 6 */
8class ConfigPhpTest extends PHPUnit_Framework_TestCase 7class ConfigPhpTest extends \PHPUnit_Framework_TestCase
9{ 8{
10 /** 9 /**
11 * @var ConfigPhp 10 * @var ConfigPhp
@@ -38,6 +37,20 @@ class ConfigPhpTest extends PHPUnit_Framework_TestCase
38 } 37 }
39 38
40 /** 39 /**
40 * Read an empty existent config file -> array with blank default values.
41 */
42 public function testReadEmpty()
43 {
44 $dataFile = 'tests/utils/config/emptyConfigPhp.php';
45 $conf = $this->configIO->read($dataFile);
46 $this->assertEmpty($conf['login']);
47 $this->assertEmpty($conf['title']);
48 $this->assertEmpty($conf['titleLink']);
49 $this->assertEmpty($conf['config']);
50 $this->assertEmpty($conf['plugins']);
51 }
52
53 /**
41 * Write a new config file. 54 * Write a new config file.
42 */ 55 */
43 public function testWriteNew() 56 public function testWriteNew()
diff --git a/tests/config/ConfigPluginTest.php b/tests/config/ConfigPluginTest.php
index 3b37cd79..deb02c9e 100644
--- a/tests/config/ConfigPluginTest.php
+++ b/tests/config/ConfigPluginTest.php
@@ -1,14 +1,14 @@
1<?php 1<?php
2/** 2namespace Shaarli\Config;
3 * Config' tests 3
4 */ 4use Shaarli\Config\Exception\PluginConfigOrderException;
5 5
6require_once 'application/config/ConfigPlugin.php'; 6require_once 'application/config/ConfigPlugin.php';
7 7
8/** 8/**
9 * Unitary tests for Shaarli config related functions 9 * Unitary tests for Shaarli config related functions
10 */ 10 */
11class ConfigPluginTest extends PHPUnit_Framework_TestCase 11class ConfigPluginTest extends \PHPUnit_Framework_TestCase
12{ 12{
13 /** 13 /**
14 * Test save_plugin_config with valid data. 14 * Test save_plugin_config with valid data.
@@ -39,7 +39,7 @@ class ConfigPluginTest extends PHPUnit_Framework_TestCase
39 /** 39 /**
40 * Test save_plugin_config with invalid data. 40 * Test save_plugin_config with invalid data.
41 * 41 *
42 * @expectedException PluginConfigOrderException 42 * @expectedException Shaarli\Config\Exception\PluginConfigOrderException
43 */ 43 */
44 public function testSavePluginConfigInvalid() 44 public function testSavePluginConfigInvalid()
45 { 45 {