aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/updater/DummyUpdater.php (renamed from tests/Updater/DummyUpdater.php)9
-rw-r--r--tests/updater/UpdaterTest.php (renamed from tests/Updater/UpdaterTest.php)29
-rw-r--r--tests/utils/config/configPhp.php2
3 files changed, 24 insertions, 16 deletions
diff --git a/tests/Updater/DummyUpdater.php b/tests/updater/DummyUpdater.php
index 3c74b4ff..9e866f1f 100644
--- a/tests/Updater/DummyUpdater.php
+++ b/tests/updater/DummyUpdater.php
@@ -1,12 +1,15 @@
1<?php 1<?php
2namespace Shaarli\Updater;
2 3
4use Exception;
5use ReflectionClass;
6use ReflectionMethod;
3use Shaarli\Bookmark\LinkDB; 7use Shaarli\Bookmark\LinkDB;
4 8use Shaarli\Config\ConfigManager;
5require_once 'application/Updater.php';
6 9
7/** 10/**
8 * Class DummyUpdater. 11 * Class DummyUpdater.
9 * Extends Updater to add update method designed for unit tests. 12 * Extends updater to add update method designed for unit tests.
10 */ 13 */
11class DummyUpdater extends Updater 14class DummyUpdater extends Updater
12{ 15{
diff --git a/tests/Updater/UpdaterTest.php b/tests/updater/UpdaterTest.php
index f910e054..d7df5963 100644
--- a/tests/Updater/UpdaterTest.php
+++ b/tests/updater/UpdaterTest.php
@@ -1,19 +1,24 @@
1<?php 1<?php
2namespace Shaarli\Updater;
2 3
4use DateTime;
5use Exception;
3use Shaarli\Bookmark\LinkDB; 6use Shaarli\Bookmark\LinkDB;
4use Shaarli\Config\ConfigJson; 7use Shaarli\Config\ConfigJson;
5use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
6use Shaarli\Config\ConfigPhp; 9use Shaarli\Config\ConfigPhp;
7use Shaarli\Thumbnailer; 10use Shaarli\Thumbnailer;
8 11
9require_once 'tests/Updater/DummyUpdater.php'; 12require_once 'application/updater/UpdaterUtils.php';
13require_once 'tests/updater/DummyUpdater.php';
14require_once 'tests/utils/ReferenceLinkDB.php';
10require_once 'inc/rain.tpl.class.php'; 15require_once 'inc/rain.tpl.class.php';
11 16
12/** 17/**
13 * Class UpdaterTest. 18 * Class UpdaterTest.
14 * Runs unit tests against the Updater class. 19 * Runs unit tests against the updater class.
15 */ 20 */
16class UpdaterTest extends PHPUnit_Framework_TestCase 21class UpdaterTest extends \PHPUnit\Framework\TestCase
17{ 22{
18 /** 23 /**
19 * @var string Path to test datastore. 24 * @var string Path to test datastore.
@@ -155,7 +160,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
155 /** 160 /**
156 * Test Update failed. 161 * Test Update failed.
157 * 162 *
158 * @expectedException UpdaterException 163 * @expectedException \Exception
159 */ 164 */
160 public function testUpdateFailed() 165 public function testUpdateFailed()
161 { 166 {
@@ -181,17 +186,17 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
181 $this->conf->setConfigFile('tests/utils/config/configPhp'); 186 $this->conf->setConfigFile('tests/utils/config/configPhp');
182 $this->conf->reset(); 187 $this->conf->reset();
183 188
184 $optionsFile = 'tests/Updater/options.php'; 189 $optionsFile = 'tests/updater/options.php';
185 $options = '<?php 190 $options = '<?php
186$GLOBALS[\'privateLinkByDefault\'] = true;'; 191$GLOBALS[\'privateLinkByDefault\'] = true;';
187 file_put_contents($optionsFile, $options); 192 file_put_contents($optionsFile, $options);
188 193
189 // tmp config file. 194 // tmp config file.
190 $this->conf->setConfigFile('tests/Updater/config'); 195 $this->conf->setConfigFile('tests/updater/config');
191 196
192 // merge configs 197 // merge configs
193 $updater = new Updater(array(), array(), $this->conf, true); 198 $updater = new Updater(array(), array(), $this->conf, true);
194 // This writes a new config file in tests/Updater/config.php 199 // This writes a new config file in tests/updater/config.php
195 $updater->updateMethodMergeDeprecatedConfigFile(); 200 $updater->updateMethodMergeDeprecatedConfigFile();
196 201
197 // make sure updated field is changed 202 // make sure updated field is changed
@@ -218,7 +223,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
218 */ 223 */
219 public function testRenameDashTags() 224 public function testRenameDashTags()
220 { 225 {
221 $refDB = new ReferenceLinkDB(); 226 $refDB = new \ReferenceLinkDB();
222 $refDB->write(self::$testDatastore); 227 $refDB->write(self::$testDatastore);
223 $linkDB = new LinkDB(self::$testDatastore, true, false); 228 $linkDB = new LinkDB(self::$testDatastore, true, false);
224 229
@@ -364,7 +369,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
364 'private' => true, 369 'private' => true,
365 ), 370 ),
366 ); 371 );
367 $refDB = new ReferenceLinkDB(); 372 $refDB = new \ReferenceLinkDB();
368 $refDB->setLinks($links); 373 $refDB->setLinks($links);
369 $refDB->write(self::$testDatastore); 374 $refDB->write(self::$testDatastore);
370 $linkDB = new LinkDB(self::$testDatastore, true, false); 375 $linkDB = new LinkDB(self::$testDatastore, true, false);
@@ -428,7 +433,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
428 */ 433 */
429 public function testDatastoreIdsNothingToDo() 434 public function testDatastoreIdsNothingToDo()
430 { 435 {
431 $refDB = new ReferenceLinkDB(); 436 $refDB = new \ReferenceLinkDB();
432 $refDB->write(self::$testDatastore); 437 $refDB->write(self::$testDatastore);
433 $linkDB = new LinkDB(self::$testDatastore, true, false); 438 $linkDB = new LinkDB(self::$testDatastore, true, false);
434 439
@@ -765,7 +770,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
765 1 => ['id' => 1] + $blank, 770 1 => ['id' => 1] + $blank,
766 2 => ['id' => 2] + $blank, 771 2 => ['id' => 2] + $blank,
767 ]; 772 ];
768 $refDB = new ReferenceLinkDB(); 773 $refDB = new \ReferenceLinkDB();
769 $refDB->setLinks($links); 774 $refDB->setLinks($links);
770 $refDB->write(self::$testDatastore); 775 $refDB->write(self::$testDatastore);
771 $linkDB = new LinkDB(self::$testDatastore, true, false); 776 $linkDB = new LinkDB(self::$testDatastore, true, false);
@@ -796,7 +801,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
796 1 => ['id' => 1, 'sticky' => true] + $blank, 801 1 => ['id' => 1, 'sticky' => true] + $blank,
797 2 => ['id' => 2] + $blank, 802 2 => ['id' => 2] + $blank,
798 ]; 803 ];
799 $refDB = new ReferenceLinkDB(); 804 $refDB = new \ReferenceLinkDB();
800 $refDB->setLinks($links); 805 $refDB->setLinks($links);
801 $refDB->write(self::$testDatastore); 806 $refDB->write(self::$testDatastore);
802 $linkDB = new LinkDB(self::$testDatastore, true, false); 807 $linkDB = new LinkDB(self::$testDatastore, true, false);
diff --git a/tests/utils/config/configPhp.php b/tests/utils/config/configPhp.php
index 34b11fcd..7dc81e22 100644
--- a/tests/utils/config/configPhp.php
+++ b/tests/utils/config/configPhp.php
@@ -8,7 +8,7 @@ $GLOBALS['titleLink'] = 'titleLink';
8$GLOBALS['redirector'] = 'lala'; 8$GLOBALS['redirector'] = 'lala';
9$GLOBALS['disablesessionprotection'] = false; 9$GLOBALS['disablesessionprotection'] = false;
10$GLOBALS['privateLinkByDefault'] = false; 10$GLOBALS['privateLinkByDefault'] = false;
11$GLOBALS['config']['DATADIR'] = 'tests/Updater'; 11$GLOBALS['config']['DATADIR'] = 'tests/updater';
12$GLOBALS['config']['PAGECACHE'] = 'sandbox/pagecache'; 12$GLOBALS['config']['PAGECACHE'] = 'sandbox/pagecache';
13$GLOBALS['config']['DATASTORE'] = 'data/datastore.php'; 13$GLOBALS['config']['DATASTORE'] = 'data/datastore.php';
14$GLOBALS['plugins']['WALLABAG_VERSION'] = '1'; 14$GLOBALS['plugins']['WALLABAG_VERSION'] = '1';