aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'tests/legacy')
-rw-r--r--tests/legacy/LegacyLinkDBTest.php13
-rw-r--r--tests/legacy/LegacyLinkFilterTest.php12
-rw-r--r--tests/legacy/LegacyUpdaterTest.php14
3 files changed, 22 insertions, 17 deletions
diff --git a/tests/legacy/LegacyLinkDBTest.php b/tests/legacy/LegacyLinkDBTest.php
index 0884ad03..819bc272 100644
--- a/tests/legacy/LegacyLinkDBTest.php
+++ b/tests/legacy/LegacyLinkDBTest.php
@@ -52,7 +52,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
52 * 52 *
53 * Resets test data for each test 53 * Resets test data for each test
54 */ 54 */
55 protected function setUp() 55 protected function setUp(): void
56 { 56 {
57 if (file_exists(self::$testDatastore)) { 57 if (file_exists(self::$testDatastore)) {
58 unlink(self::$testDatastore); 58 unlink(self::$testDatastore);
@@ -101,10 +101,11 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
101 * Attempt to instantiate a LinkDB whereas the datastore is not writable 101 * Attempt to instantiate a LinkDB whereas the datastore is not writable
102 * 102 *
103 * @expectedException Shaarli\Exceptions\IOException 103 * @expectedException Shaarli\Exceptions\IOException
104 * @expectedExceptionMessageRegExp /Error accessing "null"/
105 */ 104 */
106 public function testConstructDatastoreNotWriteable() 105 public function testConstructDatastoreNotWriteable()
107 { 106 {
107 $this->expectExceptionMessageRegExp('/Error accessing "null"/');
108
108 new LegacyLinkDB('null/store.db', false, false); 109 new LegacyLinkDB('null/store.db', false, false);
109 } 110 }
110 111
@@ -420,22 +421,22 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
420 421
421 /** 422 /**
422 * Test filterHash() with an invalid smallhash. 423 * Test filterHash() with an invalid smallhash.
423 *
424 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
425 */ 424 */
426 public function testFilterHashInValid1() 425 public function testFilterHashInValid1()
427 { 426 {
427 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
428
428 $request = 'blabla'; 429 $request = 'blabla';
429 self::$publicLinkDB->filterHash($request); 430 self::$publicLinkDB->filterHash($request);
430 } 431 }
431 432
432 /** 433 /**
433 * Test filterHash() with an empty smallhash. 434 * Test filterHash() with an empty smallhash.
434 *
435 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
436 */ 435 */
437 public function testFilterHashInValid() 436 public function testFilterHashInValid()
438 { 437 {
438 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
439
439 self::$publicLinkDB->filterHash(''); 440 self::$publicLinkDB->filterHash('');
440 } 441 }
441 442
diff --git a/tests/legacy/LegacyLinkFilterTest.php b/tests/legacy/LegacyLinkFilterTest.php
index ba9ec529..9db921a9 100644
--- a/tests/legacy/LegacyLinkFilterTest.php
+++ b/tests/legacy/LegacyLinkFilterTest.php
@@ -34,7 +34,7 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
34 /** 34 /**
35 * Instantiate linkFilter with ReferenceLinkDB data. 35 * Instantiate linkFilter with ReferenceLinkDB data.
36 */ 36 */
37 public static function setUpBeforeClass() 37 public static function setUpBeforeClass(): void
38 { 38 {
39 self::$refDB = new ReferenceLinkDB(true); 39 self::$refDB = new ReferenceLinkDB(true);
40 self::$refDB->write(self::$testDatastore); 40 self::$refDB->write(self::$testDatastore);
@@ -198,20 +198,22 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
198 /** 198 /**
199 * Use an invalid date format 199 * Use an invalid date format
200 * @expectedException Exception 200 * @expectedException Exception
201 * @expectedExceptionMessageRegExp /Invalid date format/
202 */ 201 */
203 public function testFilterInvalidDayWithChars() 202 public function testFilterInvalidDayWithChars()
204 { 203 {
204 $this->expectExceptionMessageRegExp('/Invalid date format/');
205
205 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away'); 206 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away');
206 } 207 }
207 208
208 /** 209 /**
209 * Use an invalid date format 210 * Use an invalid date format
210 * @expectedException Exception 211 * @expectedException Exception
211 * @expectedExceptionMessageRegExp /Invalid date format/
212 */ 212 */
213 public function testFilterInvalidDayDigits() 213 public function testFilterInvalidDayDigits()
214 { 214 {
215 $this->expectExceptionMessageRegExp('/Invalid date format/');
216
215 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20'); 217 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20');
216 } 218 }
217 219
@@ -235,11 +237,11 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
235 237
236 /** 238 /**
237 * No link for this hash 239 * No link for this hash
238 *
239 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
240 */ 240 */
241 public function testFilterUnknownSmallHash() 241 public function testFilterUnknownSmallHash()
242 { 242 {
243 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
244
243 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah'); 245 self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah');
244 } 246 }
245 247
diff --git a/tests/legacy/LegacyUpdaterTest.php b/tests/legacy/LegacyUpdaterTest.php
index 7c429811..acfac530 100644
--- a/tests/legacy/LegacyUpdaterTest.php
+++ b/tests/legacy/LegacyUpdaterTest.php
@@ -40,7 +40,7 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
40 /** 40 /**
41 * Executed before each test. 41 * Executed before each test.
42 */ 42 */
43 public function setUp() 43 protected function setUp(): void
44 { 44 {
45 copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); 45 copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
46 $this->conf = new ConfigManager(self::$configFile); 46 $this->conf = new ConfigManager(self::$configFile);
@@ -82,10 +82,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
82 * Test errors in UpdaterUtils::write_updates_file(): empty updates file. 82 * Test errors in UpdaterUtils::write_updates_file(): empty updates file.
83 * 83 *
84 * @expectedException Exception 84 * @expectedException Exception
85 * @expectedExceptionMessageRegExp /Updates file path is not set(.*)/
86 */ 85 */
87 public function testWriteEmptyUpdatesFile() 86 public function testWriteEmptyUpdatesFile()
88 { 87 {
88 $this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
89
89 UpdaterUtils::write_updates_file('', array('test')); 90 UpdaterUtils::write_updates_file('', array('test'));
90 } 91 }
91 92
@@ -93,10 +94,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
93 * Test errors in UpdaterUtils::write_updates_file(): not writable updates file. 94 * Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
94 * 95 *
95 * @expectedException Exception 96 * @expectedException Exception
96 * @expectedExceptionMessageRegExp /Unable to write(.*)/
97 */ 97 */
98 public function testWriteUpdatesFileNotWritable() 98 public function testWriteUpdatesFileNotWritable()
99 { 99 {
100 $this->expectExceptionMessageRegExp('/Unable to write(.*)/');
101
100 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; 102 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
101 touch($updatesFile); 103 touch($updatesFile);
102 chmod($updatesFile, 0444); 104 chmod($updatesFile, 0444);
@@ -161,11 +163,11 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
161 163
162 /** 164 /**
163 * Test Update failed. 165 * Test Update failed.
164 *
165 * @expectedException \Exception
166 */ 166 */
167 public function testUpdateFailed() 167 public function testUpdateFailed()
168 { 168 {
169 $this->expectException(\Exception::class);
170
169 $updates = array( 171 $updates = array(
170 'updateMethodDummy1', 172 'updateMethodDummy1',
171 'updateMethodDummy2', 173 'updateMethodDummy2',
@@ -754,7 +756,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
754 if (isset($_SESSION['warnings'])) { 756 if (isset($_SESSION['warnings'])) {
755 unset($_SESSION['warnings']); 757 unset($_SESSION['warnings']);
756 } 758 }
757 759
758 $updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION); 760 $updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION);
759 $this->assertTrue($updater->updateMethodWebThumbnailer()); 761 $this->assertTrue($updater->updateMethodWebThumbnailer());
760 $this->assertFalse($this->conf->exists('thumbnail')); 762 $this->assertFalse($this->conf->exists('thumbnail'));