aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/bookmark/BookmarkFileServiceTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-09-27 14:07:08 +0200
committerArthurHoaro <arthur@hoa.ro>2020-09-27 14:09:55 +0200
commitb1baca99f280570d0336b4d71ad1f9dca213a35b (patch)
tree518de2057da549d0baa982c6aa689aa813377774 /tests/bookmark/BookmarkFileServiceTest.php
parent8f60e1206e45e67c96a7630d4ff94e72fe875f09 (diff)
downloadShaarli-b1baca99f280570d0336b4d71ad1f9dca213a35b.tar.gz
Shaarli-b1baca99f280570d0336b4d71ad1f9dca213a35b.tar.zst
Shaarli-b1baca99f280570d0336b4d71ad1f9dca213a35b.zip
Convert legacy PHPUnit @expected* to new ->expect*
Converted automatically using https://github.com/ArthurHoaro/convert-legacy-phpunit-expect
Diffstat (limited to 'tests/bookmark/BookmarkFileServiceTest.php')
-rw-r--r--tests/bookmark/BookmarkFileServiceTest.php84
1 files changed, 42 insertions, 42 deletions
diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php
index aed4dc76..9cff0fb3 100644
--- a/tests/bookmark/BookmarkFileServiceTest.php
+++ b/tests/bookmark/BookmarkFileServiceTest.php
@@ -134,11 +134,11 @@ class BookmarkFileServiceTest extends TestCase
134 134
135 /** 135 /**
136 * Test get() method for an undefined bookmark 136 * Test get() method for an undefined bookmark
137 *
138 * @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
139 */ 137 */
140 public function testGetUndefined() 138 public function testGetUndefined()
141 { 139 {
140 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
141
142 $this->privateLinkDB->get(666); 142 $this->privateLinkDB->get(666);
143 } 143 }
144 144
@@ -230,13 +230,13 @@ class BookmarkFileServiceTest extends TestCase
230 230
231 /** 231 /**
232 * Test add() method for a bookmark without any field set and without writing the data store 232 * Test add() method for a bookmark without any field set and without writing the data store
233 *
234 * @expectedExceptionMessage Shaarli\Bookmark\Exception\BookmarkNotFoundException
235 */ 233 */
236 public function testAddMinimalNoWrite() 234 public function testAddMinimalNoWrite()
237 { 235 {
236 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
237
238 $bookmark = new Bookmark(); 238 $bookmark = new Bookmark();
239 $this->privateLinkDB->add($bookmark); 239 $this->privateLinkDB->add($bookmark, false);
240 240
241 $bookmark = $this->privateLinkDB->get(43); 241 $bookmark = $this->privateLinkDB->get(43);
242 $this->assertEquals(43, $bookmark->getId()); 242 $this->assertEquals(43, $bookmark->getId());
@@ -249,34 +249,34 @@ class BookmarkFileServiceTest extends TestCase
249 249
250 /** 250 /**
251 * Test add() method while logged out 251 * Test add() method while logged out
252 *
253 * @expectedException \Exception
254 * @expectedExceptionMessage You're not authorized to alter the datastore
255 */ 252 */
256 public function testAddLoggedOut() 253 public function testAddLoggedOut()
257 { 254 {
255 $this->expectException(\Exception::class);
256 $this->expectExceptionMessage('You\'re not authorized to alter the datastore');
257
258 $this->publicLinkDB->add(new Bookmark()); 258 $this->publicLinkDB->add(new Bookmark());
259 } 259 }
260 260
261 /** 261 /**
262 * Test add() method with an entry which is not a bookmark instance 262 * Test add() method with an entry which is not a bookmark instance
263 *
264 * @expectedException \Exception
265 * @expectedExceptionMessage Provided data is invalid
266 */ 263 */
267 public function testAddNotABookmark() 264 public function testAddNotABookmark()
268 { 265 {
266 $this->expectException(\Exception::class);
267 $this->expectExceptionMessage('Provided data is invalid');
268
269 $this->privateLinkDB->add(['title' => 'hi!']); 269 $this->privateLinkDB->add(['title' => 'hi!']);
270 } 270 }
271 271
272 /** 272 /**
273 * Test add() method with a Bookmark already containing an ID 273 * Test add() method with a Bookmark already containing an ID
274 *
275 * @expectedException \Exception
276 * @expectedExceptionMessage This bookmarks already exists
277 */ 274 */
278 public function testAddWithId() 275 public function testAddWithId()
279 { 276 {
277 $this->expectException(\Exception::class);
278 $this->expectExceptionMessage('This bookmarks already exists');
279
280 $bookmark = new Bookmark(); 280 $bookmark = new Bookmark();
281 $bookmark->setId(43); 281 $bookmark->setId(43);
282 $this->privateLinkDB->add($bookmark); 282 $this->privateLinkDB->add($bookmark);
@@ -397,44 +397,44 @@ class BookmarkFileServiceTest extends TestCase
397 397
398 /** 398 /**
399 * Test set() method while logged out 399 * Test set() method while logged out
400 *
401 * @expectedException \Exception
402 * @expectedExceptionMessage You're not authorized to alter the datastore
403 */ 400 */
404 public function testSetLoggedOut() 401 public function testSetLoggedOut()
405 { 402 {
403 $this->expectException(\Exception::class);
404 $this->expectExceptionMessage('You\'re not authorized to alter the datastore');
405
406 $this->publicLinkDB->set(new Bookmark()); 406 $this->publicLinkDB->set(new Bookmark());
407 } 407 }
408 408
409 /** 409 /**
410 * Test set() method with an entry which is not a bookmark instance 410 * Test set() method with an entry which is not a bookmark instance
411 *
412 * @expectedException \Exception
413 * @expectedExceptionMessage Provided data is invalid
414 */ 411 */
415 public function testSetNotABookmark() 412 public function testSetNotABookmark()
416 { 413 {
414 $this->expectException(\Exception::class);
415 $this->expectExceptionMessage('Provided data is invalid');
416
417 $this->privateLinkDB->set(['title' => 'hi!']); 417 $this->privateLinkDB->set(['title' => 'hi!']);
418 } 418 }
419 419
420 /** 420 /**
421 * Test set() method with a Bookmark without an ID defined. 421 * Test set() method with a Bookmark without an ID defined.
422 *
423 * @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
424 */ 422 */
425 public function testSetWithoutId() 423 public function testSetWithoutId()
426 { 424 {
425 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
426
427 $bookmark = new Bookmark(); 427 $bookmark = new Bookmark();
428 $this->privateLinkDB->set($bookmark); 428 $this->privateLinkDB->set($bookmark);
429 } 429 }
430 430
431 /** 431 /**
432 * Test set() method with a Bookmark with an unknow ID 432 * Test set() method with a Bookmark with an unknow ID
433 *
434 * @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
435 */ 433 */
436 public function testSetWithUnknownId() 434 public function testSetWithUnknownId()
437 { 435 {
436 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
437
438 $bookmark = new Bookmark(); 438 $bookmark = new Bookmark();
439 $bookmark->setId(666); 439 $bookmark->setId(666);
440 $this->privateLinkDB->set($bookmark); 440 $this->privateLinkDB->set($bookmark);
@@ -481,23 +481,23 @@ class BookmarkFileServiceTest extends TestCase
481 481
482 /** 482 /**
483 * Test addOrSet() method while logged out 483 * Test addOrSet() method while logged out
484 *
485 * @expectedException \Exception
486 * @expectedExceptionMessage You're not authorized to alter the datastore
487 */ 484 */
488 public function testAddOrSetLoggedOut() 485 public function testAddOrSetLoggedOut()
489 { 486 {
487 $this->expectException(\Exception::class);
488 $this->expectExceptionMessage('You\'re not authorized to alter the datastore');
489
490 $this->publicLinkDB->addOrSet(new Bookmark()); 490 $this->publicLinkDB->addOrSet(new Bookmark());
491 } 491 }
492 492
493 /** 493 /**
494 * Test addOrSet() method with an entry which is not a bookmark instance 494 * Test addOrSet() method with an entry which is not a bookmark instance
495 *
496 * @expectedException \Exception
497 * @expectedExceptionMessage Provided data is invalid
498 */ 495 */
499 public function testAddOrSetNotABookmark() 496 public function testAddOrSetNotABookmark()
500 { 497 {
498 $this->expectException(\Exception::class);
499 $this->expectExceptionMessage('Provided data is invalid');
500
501 $this->privateLinkDB->addOrSet(['title' => 'hi!']); 501 $this->privateLinkDB->addOrSet(['title' => 'hi!']);
502 } 502 }
503 503
@@ -524,11 +524,11 @@ class BookmarkFileServiceTest extends TestCase
524 524
525 /** 525 /**
526 * Test remove() method with an existing Bookmark 526 * Test remove() method with an existing Bookmark
527 *
528 * @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
529 */ 527 */
530 public function testRemoveExisting() 528 public function testRemoveExisting()
531 { 529 {
530 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
531
532 $bookmark = $this->privateLinkDB->get(42); 532 $bookmark = $this->privateLinkDB->get(42);
533 $this->privateLinkDB->remove($bookmark); 533 $this->privateLinkDB->remove($bookmark);
534 534
@@ -548,34 +548,34 @@ class BookmarkFileServiceTest extends TestCase
548 548
549 /** 549 /**
550 * Test remove() method while logged out 550 * Test remove() method while logged out
551 *
552 * @expectedException \Exception
553 * @expectedExceptionMessage You're not authorized to alter the datastore
554 */ 551 */
555 public function testRemoveLoggedOut() 552 public function testRemoveLoggedOut()
556 { 553 {
554 $this->expectException(\Exception::class);
555 $this->expectExceptionMessage('You\'re not authorized to alter the datastore');
556
557 $bookmark = $this->privateLinkDB->get(42); 557 $bookmark = $this->privateLinkDB->get(42);
558 $this->publicLinkDB->remove($bookmark); 558 $this->publicLinkDB->remove($bookmark);
559 } 559 }
560 560
561 /** 561 /**
562 * Test remove() method with an entry which is not a bookmark instance 562 * Test remove() method with an entry which is not a bookmark instance
563 *
564 * @expectedException \Exception
565 * @expectedExceptionMessage Provided data is invalid
566 */ 563 */
567 public function testRemoveNotABookmark() 564 public function testRemoveNotABookmark()
568 { 565 {
566 $this->expectException(\Exception::class);
567 $this->expectExceptionMessage('Provided data is invalid');
568
569 $this->privateLinkDB->remove(['title' => 'hi!']); 569 $this->privateLinkDB->remove(['title' => 'hi!']);
570 } 570 }
571 571
572 /** 572 /**
573 * Test remove() method with a Bookmark with an unknown ID 573 * Test remove() method with a Bookmark with an unknown ID
574 *
575 * @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
576 */ 574 */
577 public function testRemoveWithUnknownId() 575 public function testRemoveWithUnknownId()
578 { 576 {
577 $this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
578
579 $bookmark = new Bookmark(); 579 $bookmark = new Bookmark();
580 $bookmark->setId(666); 580 $bookmark->setId(666);
581 $this->privateLinkDB->remove($bookmark); 581 $this->privateLinkDB->remove($bookmark);
@@ -635,15 +635,15 @@ class BookmarkFileServiceTest extends TestCase
635 * to make sure that nothing have been broken in the migration process. 635 * to make sure that nothing have been broken in the migration process.
636 * They mostly cover search/filters. Some of them might be redundant with the previous ones. 636 * They mostly cover search/filters. Some of them might be redundant with the previous ones.
637 */ 637 */
638
639 /** 638 /**
640 * Attempt to instantiate a LinkDB whereas the datastore is not writable 639 * Attempt to instantiate a LinkDB whereas the datastore is not writable
641 * 640 *
642 * @expectedException Shaarli\Bookmark\Exception\NotWritableDataStoreException 641 * @expectedException Shaarli\Bookmark\Exception\NotWritableDataStoreException
643 * @expectedExceptionMessageRegExp #Couldn't load data from the data store file "null".*#
644 */ 642 */
645 public function testConstructDatastoreNotWriteable() 643 public function testConstructDatastoreNotWriteable()
646 { 644 {
645 $this->expectExceptionMessageRegExp('#Couldn\'t load data from the data store file "null".*#');
646
647 $conf = new ConfigManager('tests/utils/config/configJson'); 647 $conf = new ConfigManager('tests/utils/config/configJson');
648 $conf->set('resource.datastore', 'null/store.db'); 648 $conf->set('resource.datastore', 'null/store.db');
649 new BookmarkFileService($conf, $this->history, true); 649 new BookmarkFileService($conf, $this->history, true);