diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-13 12:07:13 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-13 12:07:13 +0200 |
commit | d9f6275ebca035fec8331652c677981056793ccc (patch) | |
tree | 37a64baf4f0eba6b781040605965383d8aded2cc /tests/api/controllers/links/DeleteLinkTest.php | |
parent | 38672ba0d1c722e5d6d33a58255ceb55e9410e46 (diff) | |
parent | d63ff87a009313141ae684ec447b902562ff6ee7 (diff) | |
download | Shaarli-d9f6275ebca035fec8331652c677981056793ccc.tar.gz Shaarli-d9f6275ebca035fec8331652c677981056793ccc.tar.zst Shaarli-d9f6275ebca035fec8331652c677981056793ccc.zip |
Merge branch 'v0.11' into stablestable
Diffstat (limited to 'tests/api/controllers/links/DeleteLinkTest.php')
-rw-r--r-- | tests/api/controllers/links/DeleteLinkTest.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/api/controllers/links/DeleteLinkTest.php b/tests/api/controllers/links/DeleteLinkTest.php index 7d797137..90193e28 100644 --- a/tests/api/controllers/links/DeleteLinkTest.php +++ b/tests/api/controllers/links/DeleteLinkTest.php | |||
@@ -3,13 +3,15 @@ | |||
3 | 3 | ||
4 | namespace Shaarli\Api\Controllers; | 4 | namespace Shaarli\Api\Controllers; |
5 | 5 | ||
6 | use Shaarli\Bookmark\LinkDB; | ||
6 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
8 | use Shaarli\History; | ||
7 | use Slim\Container; | 9 | use Slim\Container; |
8 | use Slim\Http\Environment; | 10 | use Slim\Http\Environment; |
9 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
10 | use Slim\Http\Response; | 12 | use Slim\Http\Response; |
11 | 13 | ||
12 | class DeleteLinkTest extends \PHPUnit_Framework_TestCase | 14 | class DeleteLinkTest extends \PHPUnit\Framework\TestCase |
13 | { | 15 | { |
14 | /** | 16 | /** |
15 | * @var string datastore to test write operations | 17 | * @var string datastore to test write operations |
@@ -32,12 +34,12 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
32 | protected $refDB = null; | 34 | protected $refDB = null; |
33 | 35 | ||
34 | /** | 36 | /** |
35 | * @var \LinkDB instance. | 37 | * @var LinkDB instance. |
36 | */ | 38 | */ |
37 | protected $linkDB; | 39 | protected $linkDB; |
38 | 40 | ||
39 | /** | 41 | /** |
40 | * @var \History instance. | 42 | * @var HistoryController instance. |
41 | */ | 43 | */ |
42 | protected $history; | 44 | protected $history; |
43 | 45 | ||
@@ -59,10 +61,10 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
59 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 61 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
60 | $this->refDB = new \ReferenceLinkDB(); | 62 | $this->refDB = new \ReferenceLinkDB(); |
61 | $this->refDB->write(self::$testDatastore); | 63 | $this->refDB->write(self::$testDatastore); |
62 | $this->linkDB = new \LinkDB(self::$testDatastore, true, false); | 64 | $this->linkDB = new LinkDB(self::$testDatastore, true, false); |
63 | $refHistory = new \ReferenceHistory(); | 65 | $refHistory = new \ReferenceHistory(); |
64 | $refHistory->write(self::$testHistory); | 66 | $refHistory->write(self::$testHistory); |
65 | $this->history = new \History(self::$testHistory); | 67 | $this->history = new History(self::$testHistory); |
66 | $this->container = new Container(); | 68 | $this->container = new Container(); |
67 | $this->container['conf'] = $this->conf; | 69 | $this->container['conf'] = $this->conf; |
68 | $this->container['db'] = $this->linkDB; | 70 | $this->container['db'] = $this->linkDB; |
@@ -96,11 +98,11 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
96 | $this->assertEquals(204, $response->getStatusCode()); | 98 | $this->assertEquals(204, $response->getStatusCode()); |
97 | $this->assertEmpty((string) $response->getBody()); | 99 | $this->assertEmpty((string) $response->getBody()); |
98 | 100 | ||
99 | $this->linkDB = new \LinkDB(self::$testDatastore, true, false); | 101 | $this->linkDB = new LinkDB(self::$testDatastore, true, false); |
100 | $this->assertFalse(isset($this->linkDB[$id])); | 102 | $this->assertFalse(isset($this->linkDB[$id])); |
101 | 103 | ||
102 | $historyEntry = $this->history->getHistory()[0]; | 104 | $historyEntry = $this->history->getHistory()[0]; |
103 | $this->assertEquals(\History::DELETED, $historyEntry['event']); | 105 | $this->assertEquals(History::DELETED, $historyEntry['event']); |
104 | $this->assertTrue( | 106 | $this->assertTrue( |
105 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 107 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
106 | ); | 108 | ); |
@@ -110,7 +112,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase | |||
110 | /** | 112 | /** |
111 | * Test DELETE link endpoint: reach not existing ID. | 113 | * Test DELETE link endpoint: reach not existing ID. |
112 | * | 114 | * |
113 | * @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException | 115 | * @expectedException \Shaarli\Api\Exceptions\ApiLinkNotFoundException |
114 | */ | 116 | */ |
115 | public function testDeleteLink404() | 117 | public function testDeleteLink404() |
116 | { | 118 | { |