diff options
author | VirtualTam <virtualtam@flibidi.net> | 2019-01-12 23:55:38 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2019-01-13 00:04:42 +0100 |
commit | dea72c711ff740b3b829d238fcf85648465143a0 (patch) | |
tree | 5e926e36816d510e3b3a10e20b94c23f43b55092 /tests/api/controllers/tags | |
parent | a43e7842e44068584302ec1d6349155b571d9c96 (diff) | |
download | Shaarli-dea72c711ff740b3b829d238fcf85648465143a0.tar.gz Shaarli-dea72c711ff740b3b829d238fcf85648465143a0.tar.zst Shaarli-dea72c711ff740b3b829d238fcf85648465143a0.zip |
Optimize and cleanup imports
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests/api/controllers/tags')
-rw-r--r-- | tests/api/controllers/tags/DeleteTagTest.php | 22 | ||||
-rw-r--r-- | tests/api/controllers/tags/GetTagNameTest.php | 6 | ||||
-rw-r--r-- | tests/api/controllers/tags/GetTagsTest.php | 8 | ||||
-rw-r--r-- | tests/api/controllers/tags/PutTagTest.php | 17 |
4 files changed, 28 insertions, 25 deletions
diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php index 02803ba2..84e1d56e 100644 --- a/tests/api/controllers/tags/DeleteTagTest.php +++ b/tests/api/controllers/tags/DeleteTagTest.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 DeleteTagTest extends \PHPUnit_Framework_TestCase | 14 | class DeleteTagTest 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 DeleteTagTest extends \PHPUnit_Framework_TestCase | |||
32 | protected $refDB = null; | 34 | protected $refDB = null; |
33 | 35 | ||
34 | /** | 36 | /** |
35 | * @var \Shaarli\Bookmark\LinkDB instance. | 37 | * @var LinkDB instance. |
36 | */ | 38 | */ |
37 | protected $linkDB; | 39 | protected $linkDB; |
38 | 40 | ||
39 | /** | 41 | /** |
40 | * @var \Shaarli\History instance. | 42 | * @var HistoryController instance. |
41 | */ | 43 | */ |
42 | protected $history; | 44 | protected $history; |
43 | 45 | ||
@@ -59,10 +61,10 @@ class DeleteTagTest 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 \Shaarli\Bookmark\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 \Shaarli\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; |
@@ -97,18 +99,18 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase | |||
97 | $this->assertEquals(204, $response->getStatusCode()); | 99 | $this->assertEquals(204, $response->getStatusCode()); |
98 | $this->assertEmpty((string) $response->getBody()); | 100 | $this->assertEmpty((string) $response->getBody()); |
99 | 101 | ||
100 | $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 102 | $this->linkDB = new LinkDB(self::$testDatastore, true, false); |
101 | $tags = $this->linkDB->linksCountPerTag(); | 103 | $tags = $this->linkDB->linksCountPerTag(); |
102 | $this->assertFalse(isset($tags[$tagName])); | 104 | $this->assertFalse(isset($tags[$tagName])); |
103 | 105 | ||
104 | // 2 links affected | 106 | // 2 links affected |
105 | $historyEntry = $this->history->getHistory()[0]; | 107 | $historyEntry = $this->history->getHistory()[0]; |
106 | $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); | 108 | $this->assertEquals(History::UPDATED, $historyEntry['event']); |
107 | $this->assertTrue( | 109 | $this->assertTrue( |
108 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 110 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
109 | ); | 111 | ); |
110 | $historyEntry = $this->history->getHistory()[1]; | 112 | $historyEntry = $this->history->getHistory()[1]; |
111 | $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); | 113 | $this->assertEquals(History::UPDATED, $historyEntry['event']); |
112 | $this->assertTrue( | 114 | $this->assertTrue( |
113 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 115 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
114 | ); | 116 | ); |
@@ -131,13 +133,13 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase | |||
131 | $this->assertEquals(204, $response->getStatusCode()); | 133 | $this->assertEquals(204, $response->getStatusCode()); |
132 | $this->assertEmpty((string) $response->getBody()); | 134 | $this->assertEmpty((string) $response->getBody()); |
133 | 135 | ||
134 | $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 136 | $this->linkDB = new LinkDB(self::$testDatastore, true, false); |
135 | $tags = $this->linkDB->linksCountPerTag(); | 137 | $tags = $this->linkDB->linksCountPerTag(); |
136 | $this->assertFalse(isset($tags[$tagName])); | 138 | $this->assertFalse(isset($tags[$tagName])); |
137 | $this->assertTrue($tags[strtolower($tagName)] > 0); | 139 | $this->assertTrue($tags[strtolower($tagName)] > 0); |
138 | 140 | ||
139 | $historyEntry = $this->history->getHistory()[0]; | 141 | $historyEntry = $this->history->getHistory()[0]; |
140 | $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); | 142 | $this->assertEquals(History::UPDATED, $historyEntry['event']); |
141 | $this->assertTrue( | 143 | $this->assertTrue( |
142 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 144 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
143 | ); | 145 | ); |
diff --git a/tests/api/controllers/tags/GetTagNameTest.php b/tests/api/controllers/tags/GetTagNameTest.php index 8e0feccd..a2525c17 100644 --- a/tests/api/controllers/tags/GetTagNameTest.php +++ b/tests/api/controllers/tags/GetTagNameTest.php | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Api\Controllers; | 3 | namespace Shaarli\Api\Controllers; |
4 | 4 | ||
5 | use Shaarli\Bookmark\LinkDB; | ||
5 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
6 | |||
7 | use Slim\Container; | 7 | use Slim\Container; |
8 | use Slim\Http\Environment; | 8 | use Slim\Http\Environment; |
9 | use Slim\Http\Request; | 9 | use Slim\Http\Request; |
@@ -16,7 +16,7 @@ use Slim\Http\Response; | |||
16 | * | 16 | * |
17 | * @package Shaarli\Api\Controllers | 17 | * @package Shaarli\Api\Controllers |
18 | */ | 18 | */ |
19 | class GetTagNameTest extends \PHPUnit_Framework_TestCase | 19 | class GetTagNameTest extends \PHPUnit\Framework\TestCase |
20 | { | 20 | { |
21 | /** | 21 | /** |
22 | * @var string datastore to test write operations | 22 | * @var string datastore to test write operations |
@@ -59,7 +59,7 @@ class GetTagNameTest extends \PHPUnit_Framework_TestCase | |||
59 | 59 | ||
60 | $this->container = new Container(); | 60 | $this->container = new Container(); |
61 | $this->container['conf'] = $this->conf; | 61 | $this->container['conf'] = $this->conf; |
62 | $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 62 | $this->container['db'] = new LinkDB(self::$testDatastore, true, false); |
63 | $this->container['history'] = null; | 63 | $this->container['history'] = null; |
64 | 64 | ||
65 | $this->controller = new Tags($this->container); | 65 | $this->controller = new Tags($this->container); |
diff --git a/tests/api/controllers/tags/GetTagsTest.php b/tests/api/controllers/tags/GetTagsTest.php index f071bfa8..98628c98 100644 --- a/tests/api/controllers/tags/GetTagsTest.php +++ b/tests/api/controllers/tags/GetTagsTest.php | |||
@@ -1,8 +1,8 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Api\Controllers; | 2 | namespace Shaarli\Api\Controllers; |
3 | 3 | ||
4 | use Shaarli\Bookmark\LinkDB; | ||
4 | use Shaarli\Config\ConfigManager; | 5 | use Shaarli\Config\ConfigManager; |
5 | |||
6 | use Slim\Container; | 6 | use Slim\Container; |
7 | use Slim\Http\Environment; | 7 | use Slim\Http\Environment; |
8 | use Slim\Http\Request; | 8 | use Slim\Http\Request; |
@@ -15,7 +15,7 @@ use Slim\Http\Response; | |||
15 | * | 15 | * |
16 | * @package Shaarli\Api\Controllers | 16 | * @package Shaarli\Api\Controllers |
17 | */ | 17 | */ |
18 | class GetTagsTest extends \PHPUnit_Framework_TestCase | 18 | class GetTagsTest extends \PHPUnit\Framework\TestCase |
19 | { | 19 | { |
20 | /** | 20 | /** |
21 | * @var string datastore to test write operations | 21 | * @var string datastore to test write operations |
@@ -38,7 +38,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase | |||
38 | protected $container; | 38 | protected $container; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * @var \Shaarli\Bookmark\LinkDB instance. | 41 | * @var LinkDB instance. |
42 | */ | 42 | */ |
43 | protected $linkDB; | 43 | protected $linkDB; |
44 | 44 | ||
@@ -63,7 +63,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase | |||
63 | 63 | ||
64 | $this->container = new Container(); | 64 | $this->container = new Container(); |
65 | $this->container['conf'] = $this->conf; | 65 | $this->container['conf'] = $this->conf; |
66 | $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 66 | $this->linkDB = new LinkDB(self::$testDatastore, true, false); |
67 | $this->container['db'] = $this->linkDB; | 67 | $this->container['db'] = $this->linkDB; |
68 | $this->container['history'] = null; | 68 | $this->container['history'] = null; |
69 | 69 | ||
diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php index d8c0fec8..86106fc7 100644 --- a/tests/api/controllers/tags/PutTagTest.php +++ b/tests/api/controllers/tags/PutTagTest.php | |||
@@ -1,16 +1,17 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | |||
4 | namespace Shaarli\Api\Controllers; | 3 | namespace Shaarli\Api\Controllers; |
5 | 4 | ||
6 | use Shaarli\Api\Exceptions\ApiBadParametersException; | 5 | use Shaarli\Api\Exceptions\ApiBadParametersException; |
6 | use Shaarli\Bookmark\LinkDB; | ||
7 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
8 | use Shaarli\History; | ||
8 | use Slim\Container; | 9 | use Slim\Container; |
9 | use Slim\Http\Environment; | 10 | use Slim\Http\Environment; |
10 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
11 | use Slim\Http\Response; | 12 | use Slim\Http\Response; |
12 | 13 | ||
13 | class PutTagTest extends \PHPUnit_Framework_TestCase | 14 | class PutTagTest extends \PHPUnit\Framework\TestCase |
14 | { | 15 | { |
15 | /** | 16 | /** |
16 | * @var string datastore to test write operations | 17 | * @var string datastore to test write operations |
@@ -33,7 +34,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase | |||
33 | protected $refDB = null; | 34 | protected $refDB = null; |
34 | 35 | ||
35 | /** | 36 | /** |
36 | * @var \Shaarli\History instance. | 37 | * @var HistoryController instance. |
37 | */ | 38 | */ |
38 | protected $history; | 39 | protected $history; |
39 | 40 | ||
@@ -43,7 +44,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase | |||
43 | protected $container; | 44 | protected $container; |
44 | 45 | ||
45 | /** | 46 | /** |
46 | * @var \Shaarli\Bookmark\LinkDB instance. | 47 | * @var LinkDB instance. |
47 | */ | 48 | */ |
48 | protected $linkDB; | 49 | protected $linkDB; |
49 | 50 | ||
@@ -68,11 +69,11 @@ class PutTagTest extends \PHPUnit_Framework_TestCase | |||
68 | 69 | ||
69 | $refHistory = new \ReferenceHistory(); | 70 | $refHistory = new \ReferenceHistory(); |
70 | $refHistory->write(self::$testHistory); | 71 | $refHistory->write(self::$testHistory); |
71 | $this->history = new \Shaarli\History(self::$testHistory); | 72 | $this->history = new History(self::$testHistory); |
72 | 73 | ||
73 | $this->container = new Container(); | 74 | $this->container = new Container(); |
74 | $this->container['conf'] = $this->conf; | 75 | $this->container['conf'] = $this->conf; |
75 | $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 76 | $this->linkDB = new LinkDB(self::$testDatastore, true, false); |
76 | $this->container['db'] = $this->linkDB; | 77 | $this->container['db'] = $this->linkDB; |
77 | $this->container['history'] = $this->history; | 78 | $this->container['history'] = $this->history; |
78 | 79 | ||
@@ -113,12 +114,12 @@ class PutTagTest extends \PHPUnit_Framework_TestCase | |||
113 | $this->assertEquals(2, $tags[$newName]); | 114 | $this->assertEquals(2, $tags[$newName]); |
114 | 115 | ||
115 | $historyEntry = $this->history->getHistory()[0]; | 116 | $historyEntry = $this->history->getHistory()[0]; |
116 | $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); | 117 | $this->assertEquals(History::UPDATED, $historyEntry['event']); |
117 | $this->assertTrue( | 118 | $this->assertTrue( |
118 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 119 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
119 | ); | 120 | ); |
120 | $historyEntry = $this->history->getHistory()[1]; | 121 | $historyEntry = $this->history->getHistory()[1]; |
121 | $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); | 122 | $this->assertEquals(History::UPDATED, $historyEntry['event']); |
122 | $this->assertTrue( | 123 | $this->assertTrue( |
123 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] | 124 | (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] |
124 | ); | 125 | ); |