aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2019-01-12 23:55:38 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-13 00:04:42 +0100
commitdea72c711ff740b3b829d238fcf85648465143a0 (patch)
tree5e926e36816d510e3b3a10e20b94c23f43b55092 /tests/api
parenta43e7842e44068584302ec1d6349155b571d9c96 (diff)
downloadShaarli-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')
-rw-r--r--tests/api/ApiMiddlewareTest.php3
-rw-r--r--tests/api/ApiUtilsTest.php2
-rw-r--r--tests/api/controllers/history/HistoryTest.php28
-rw-r--r--tests/api/controllers/info/InfoTest.php3
-rw-r--r--tests/api/controllers/links/DeleteLinkTest.php18
-rw-r--r--tests/api/controllers/links/GetLinkIdTest.php3
-rw-r--r--tests/api/controllers/links/GetLinksTest.php10
-rw-r--r--tests/api/controllers/links/PostLinkTest.php9
-rw-r--r--tests/api/controllers/links/PutLinkTest.php11
-rw-r--r--tests/api/controllers/tags/DeleteTagTest.php22
-rw-r--r--tests/api/controllers/tags/GetTagNameTest.php6
-rw-r--r--tests/api/controllers/tags/GetTagsTest.php8
-rw-r--r--tests/api/controllers/tags/PutTagTest.php17
13 files changed, 72 insertions, 68 deletions
diff --git a/tests/api/ApiMiddlewareTest.php b/tests/api/ApiMiddlewareTest.php
index 23a56b1c..0b9b03f2 100644
--- a/tests/api/ApiMiddlewareTest.php
+++ b/tests/api/ApiMiddlewareTest.php
@@ -2,7 +2,6 @@
2namespace Shaarli\Api; 2namespace Shaarli\Api;
3 3
4use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
5
6use Slim\Container; 5use Slim\Container;
7use Slim\Http\Environment; 6use Slim\Http\Environment;
8use Slim\Http\Request; 7use Slim\Http\Request;
@@ -18,7 +17,7 @@ use Slim\Http\Response;
18 * 17 *
19 * @package Api 18 * @package Api
20 */ 19 */
21class ApiMiddlewareTest extends \PHPUnit_Framework_TestCase 20class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
22{ 21{
23 /** 22 /**
24 * @var string datastore to test write operations 23 * @var string datastore to test write operations
diff --git a/tests/api/ApiUtilsTest.php b/tests/api/ApiUtilsTest.php
index a1b623d8..ea0ae500 100644
--- a/tests/api/ApiUtilsTest.php
+++ b/tests/api/ApiUtilsTest.php
@@ -7,7 +7,7 @@ use Shaarli\Http\Base64Url;
7/** 7/**
8 * Class ApiUtilsTest 8 * Class ApiUtilsTest
9 */ 9 */
10class ApiUtilsTest extends \PHPUnit_Framework_TestCase 10class ApiUtilsTest extends \PHPUnit\Framework\TestCase
11{ 11{
12 /** 12 /**
13 * Force the timezone for ISO datetimes. 13 * Force the timezone for ISO datetimes.
diff --git a/tests/api/controllers/history/HistoryTest.php b/tests/api/controllers/history/HistoryTest.php
index 24efee89..e287f239 100644
--- a/tests/api/controllers/history/HistoryTest.php
+++ b/tests/api/controllers/history/HistoryTest.php
@@ -1,9 +1,9 @@
1<?php 1<?php
2 2
3
4namespace Shaarli\Api\Controllers; 3namespace Shaarli\Api\Controllers;
5 4
6use Shaarli\Config\ConfigManager; 5use Shaarli\Config\ConfigManager;
6use Shaarli\History;
7use Slim\Container; 7use Slim\Container;
8use Slim\Http\Environment; 8use Slim\Http\Environment;
9use Slim\Http\Request; 9use Slim\Http\Request;
@@ -11,7 +11,7 @@ use Slim\Http\Response;
11 11
12require_once 'tests/utils/ReferenceHistory.php'; 12require_once 'tests/utils/ReferenceHistory.php';
13 13
14class HistoryTest extends \PHPUnit_Framework_TestCase 14class HistoryTest extends \PHPUnit\Framework\TestCase
15{ 15{
16 /** 16 /**
17 * @var string datastore to test write operations 17 * @var string datastore to test write operations
@@ -34,7 +34,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
34 protected $container; 34 protected $container;
35 35
36 /** 36 /**
37 * @var History controller instance. 37 * @var HistoryController controller instance.
38 */ 38 */
39 protected $controller; 39 protected $controller;
40 40
@@ -49,9 +49,9 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
49 $this->container = new Container(); 49 $this->container = new Container();
50 $this->container['conf'] = $this->conf; 50 $this->container['conf'] = $this->conf;
51 $this->container['db'] = true; 51 $this->container['db'] = true;
52 $this->container['history'] = new \Shaarli\History(self::$testHistory); 52 $this->container['history'] = new History(self::$testHistory);
53 53
54 $this->controller = new History($this->container); 54 $this->controller = new HistoryController($this->container);
55 } 55 }
56 56
57 /** 57 /**
@@ -78,35 +78,35 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
78 78
79 $this->assertEquals($this->refHistory->count(), count($data)); 79 $this->assertEquals($this->refHistory->count(), count($data));
80 80
81 $this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); 81 $this->assertEquals(History::DELETED, $data[0]['event']);
82 $this->assertEquals( 82 $this->assertEquals(
83 \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), 83 \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
84 $data[0]['datetime'] 84 $data[0]['datetime']
85 ); 85 );
86 $this->assertEquals(124, $data[0]['id']); 86 $this->assertEquals(124, $data[0]['id']);
87 87
88 $this->assertEquals(\Shaarli\History::SETTINGS, $data[1]['event']); 88 $this->assertEquals(History::SETTINGS, $data[1]['event']);
89 $this->assertEquals( 89 $this->assertEquals(
90 \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM), 90 \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM),
91 $data[1]['datetime'] 91 $data[1]['datetime']
92 ); 92 );
93 $this->assertNull($data[1]['id']); 93 $this->assertNull($data[1]['id']);
94 94
95 $this->assertEquals(\Shaarli\History::UPDATED, $data[2]['event']); 95 $this->assertEquals(History::UPDATED, $data[2]['event']);
96 $this->assertEquals( 96 $this->assertEquals(
97 \DateTime::createFromFormat('Ymd_His', '20170301_121214')->format(\DateTime::ATOM), 97 \DateTime::createFromFormat('Ymd_His', '20170301_121214')->format(\DateTime::ATOM),
98 $data[2]['datetime'] 98 $data[2]['datetime']
99 ); 99 );
100 $this->assertEquals(123, $data[2]['id']); 100 $this->assertEquals(123, $data[2]['id']);
101 101
102 $this->assertEquals(\Shaarli\History::CREATED, $data[3]['event']); 102 $this->assertEquals(History::CREATED, $data[3]['event']);
103 $this->assertEquals( 103 $this->assertEquals(
104 \DateTime::createFromFormat('Ymd_His', '20170201_121214')->format(\DateTime::ATOM), 104 \DateTime::createFromFormat('Ymd_His', '20170201_121214')->format(\DateTime::ATOM),
105 $data[3]['datetime'] 105 $data[3]['datetime']
106 ); 106 );
107 $this->assertEquals(124, $data[3]['id']); 107 $this->assertEquals(124, $data[3]['id']);
108 108
109 $this->assertEquals(\Shaarli\History::CREATED, $data[4]['event']); 109 $this->assertEquals(History::CREATED, $data[4]['event']);
110 $this->assertEquals( 110 $this->assertEquals(
111 \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM), 111 \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM),
112 $data[4]['datetime'] 112 $data[4]['datetime']
@@ -131,7 +131,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
131 131
132 $this->assertEquals(1, count($data)); 132 $this->assertEquals(1, count($data));
133 133
134 $this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); 134 $this->assertEquals(History::DELETED, $data[0]['event']);
135 $this->assertEquals( 135 $this->assertEquals(
136 \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), 136 \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
137 $data[0]['datetime'] 137 $data[0]['datetime']
@@ -156,7 +156,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
156 156
157 $this->assertEquals(1, count($data)); 157 $this->assertEquals(1, count($data));
158 158
159 $this->assertEquals(\Shaarli\History::CREATED, $data[0]['event']); 159 $this->assertEquals(History::CREATED, $data[0]['event']);
160 $this->assertEquals( 160 $this->assertEquals(
161 \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM), 161 \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM),
162 $data[0]['datetime'] 162 $data[0]['datetime']
@@ -181,7 +181,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
181 181
182 $this->assertEquals(1, count($data)); 182 $this->assertEquals(1, count($data));
183 183
184 $this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); 184 $this->assertEquals(History::DELETED, $data[0]['event']);
185 $this->assertEquals( 185 $this->assertEquals(
186 \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), 186 \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
187 $data[0]['datetime'] 187 $data[0]['datetime']
@@ -206,7 +206,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
206 206
207 $this->assertEquals(1, count($data)); 207 $this->assertEquals(1, count($data));
208 208
209 $this->assertEquals(\Shaarli\History::SETTINGS, $data[0]['event']); 209 $this->assertEquals(History::SETTINGS, $data[0]['event']);
210 $this->assertEquals( 210 $this->assertEquals(
211 \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM), 211 \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM),
212 $data[0]['datetime'] 212 $data[0]['datetime']
diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php
index 44a9382e..e70d371b 100644
--- a/tests/api/controllers/info/InfoTest.php
+++ b/tests/api/controllers/info/InfoTest.php
@@ -2,7 +2,6 @@
2namespace Shaarli\Api\Controllers; 2namespace Shaarli\Api\Controllers;
3 3
4use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
5
6use Slim\Container; 5use Slim\Container;
7use Slim\Http\Environment; 6use Slim\Http\Environment;
8use Slim\Http\Request; 7use Slim\Http\Request;
@@ -15,7 +14,7 @@ use Slim\Http\Response;
15 * 14 *
16 * @package Api\Controllers 15 * @package Api\Controllers
17 */ 16 */
18class InfoTest extends \PHPUnit_Framework_TestCase 17class InfoTest extends \PHPUnit\Framework\TestCase
19{ 18{
20 /** 19 /**
21 * @var string datastore to test write operations 20 * @var string datastore to test write operations
diff --git a/tests/api/controllers/links/DeleteLinkTest.php b/tests/api/controllers/links/DeleteLinkTest.php
index adca9a4e..90193e28 100644
--- a/tests/api/controllers/links/DeleteLinkTest.php
+++ b/tests/api/controllers/links/DeleteLinkTest.php
@@ -3,13 +3,15 @@
3 3
4namespace Shaarli\Api\Controllers; 4namespace Shaarli\Api\Controllers;
5 5
6use Shaarli\Bookmark\LinkDB;
6use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
8use Shaarli\History;
7use Slim\Container; 9use Slim\Container;
8use Slim\Http\Environment; 10use Slim\Http\Environment;
9use Slim\Http\Request; 11use Slim\Http\Request;
10use Slim\Http\Response; 12use Slim\Http\Response;
11 13
12class DeleteLinkTest extends \PHPUnit_Framework_TestCase 14class 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 \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 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 \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;
@@ -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 \Shaarli\Bookmark\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(\Shaarli\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 {
diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php
index bf58000b..cb9b7f6a 100644
--- a/tests/api/controllers/links/GetLinkIdTest.php
+++ b/tests/api/controllers/links/GetLinkIdTest.php
@@ -3,7 +3,6 @@
3namespace Shaarli\Api\Controllers; 3namespace Shaarli\Api\Controllers;
4 4
5use Shaarli\Config\ConfigManager; 5use Shaarli\Config\ConfigManager;
6
7use Slim\Container; 6use Slim\Container;
8use Slim\Http\Environment; 7use Slim\Http\Environment;
9use Slim\Http\Request; 8use Slim\Http\Request;
@@ -18,7 +17,7 @@ use Slim\Http\Response;
18 * 17 *
19 * @package Shaarli\Api\Controllers 18 * @package Shaarli\Api\Controllers
20 */ 19 */
21class GetLinkIdTest extends \PHPUnit_Framework_TestCase 20class GetLinkIdTest extends \PHPUnit\Framework\TestCase
22{ 21{
23 /** 22 /**
24 * @var string datastore to test write operations 23 * @var string datastore to test write operations
diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php
index 1008d7b2..711a3152 100644
--- a/tests/api/controllers/links/GetLinksTest.php
+++ b/tests/api/controllers/links/GetLinksTest.php
@@ -1,8 +1,8 @@
1<?php 1<?php
2namespace Shaarli\Api\Controllers; 2namespace Shaarli\Api\Controllers;
3 3
4use Shaarli\Bookmark\LinkDB;
4use Shaarli\Config\ConfigManager; 5use Shaarli\Config\ConfigManager;
5
6use Slim\Container; 6use Slim\Container;
7use Slim\Http\Environment; 7use Slim\Http\Environment;
8use Slim\Http\Request; 8use Slim\Http\Request;
@@ -17,7 +17,7 @@ use Slim\Http\Response;
17 * 17 *
18 * @package Shaarli\Api\Controllers 18 * @package Shaarli\Api\Controllers
19 */ 19 */
20class GetLinksTest extends \PHPUnit_Framework_TestCase 20class GetLinksTest extends \PHPUnit\Framework\TestCase
21{ 21{
22 /** 22 /**
23 * @var string datastore to test write operations 23 * @var string datastore to test write operations
@@ -60,7 +60,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
60 60
61 $this->container = new Container(); 61 $this->container = new Container();
62 $this->container['conf'] = $this->conf; 62 $this->container['conf'] = $this->conf;
63 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); 63 $this->container['db'] = new LinkDB(self::$testDatastore, true, false);
64 $this->container['history'] = null; 64 $this->container['history'] = null;
65 65
66 $this->controller = new Links($this->container); 66 $this->controller = new Links($this->container);
@@ -114,7 +114,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
114 $this->assertEquals('sTuff', $first['tags'][0]); 114 $this->assertEquals('sTuff', $first['tags'][0]);
115 $this->assertEquals(false, $first['private']); 115 $this->assertEquals(false, $first['private']);
116 $this->assertEquals( 116 $this->assertEquals(
117 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), 117 \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
118 $first['created'] 118 $first['created']
119 ); 119 );
120 $this->assertEmpty($first['updated']); 120 $this->assertEmpty($first['updated']);
@@ -125,7 +125,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
125 125
126 // Update date 126 // Update date
127 $this->assertEquals( 127 $this->assertEquals(
128 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), 128 \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM),
129 $link['updated'] 129 $link['updated']
130 ); 130 );
131 } 131 }
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php
index 24e591db..d683a984 100644
--- a/tests/api/controllers/links/PostLinkTest.php
+++ b/tests/api/controllers/links/PostLinkTest.php
@@ -4,6 +4,7 @@ namespace Shaarli\Api\Controllers;
4 4
5use PHPUnit\Framework\TestCase; 5use PHPUnit\Framework\TestCase;
6use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
7use Shaarli\History;
7use Slim\Container; 8use Slim\Container;
8use Slim\Http\Environment; 9use Slim\Http\Environment;
9use Slim\Http\Request; 10use Slim\Http\Request;
@@ -40,7 +41,7 @@ class PostLinkTest extends TestCase
40 protected $refDB = null; 41 protected $refDB = null;
41 42
42 /** 43 /**
43 * @var \Shaarli\History instance. 44 * @var HistoryController instance.
44 */ 45 */
45 protected $history; 46 protected $history;
46 47
@@ -70,12 +71,12 @@ class PostLinkTest extends TestCase
70 71
71 $refHistory = new \ReferenceHistory(); 72 $refHistory = new \ReferenceHistory();
72 $refHistory->write(self::$testHistory); 73 $refHistory->write(self::$testHistory);
73 $this->history = new \Shaarli\History(self::$testHistory); 74 $this->history = new History(self::$testHistory);
74 75
75 $this->container = new Container(); 76 $this->container = new Container();
76 $this->container['conf'] = $this->conf; 77 $this->container['conf'] = $this->conf;
77 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); 78 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
78 $this->container['history'] = new \Shaarli\History(self::$testHistory); 79 $this->container['history'] = new History(self::$testHistory);
79 80
80 $this->controller = new Links($this->container); 81 $this->controller = new Links($this->container);
81 82
@@ -133,7 +134,7 @@ class PostLinkTest extends TestCase
133 $this->assertEquals('', $data['updated']); 134 $this->assertEquals('', $data['updated']);
134 135
135 $historyEntry = $this->history->getHistory()[0]; 136 $historyEntry = $this->history->getHistory()[0];
136 $this->assertEquals(\Shaarli\History::CREATED, $historyEntry['event']); 137 $this->assertEquals(History::CREATED, $historyEntry['event']);
137 $this->assertTrue( 138 $this->assertTrue(
138 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] 139 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
139 ); 140 );
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php
index eb6c7955..cd815b66 100644
--- a/tests/api/controllers/links/PutLinkTest.php
+++ b/tests/api/controllers/links/PutLinkTest.php
@@ -4,12 +4,13 @@
4namespace Shaarli\Api\Controllers; 4namespace Shaarli\Api\Controllers;
5 5
6use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
7use Shaarli\History;
7use Slim\Container; 8use Slim\Container;
8use Slim\Http\Environment; 9use Slim\Http\Environment;
9use Slim\Http\Request; 10use Slim\Http\Request;
10use Slim\Http\Response; 11use Slim\Http\Response;
11 12
12class PutLinkTest extends \PHPUnit_Framework_TestCase 13class PutLinkTest extends \PHPUnit\Framework\TestCase
13{ 14{
14 /** 15 /**
15 * @var string datastore to test write operations 16 * @var string datastore to test write operations
@@ -32,7 +33,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
32 protected $refDB = null; 33 protected $refDB = null;
33 34
34 /** 35 /**
35 * @var \Shaarli\History instance. 36 * @var HistoryController instance.
36 */ 37 */
37 protected $history; 38 protected $history;
38 39
@@ -62,12 +63,12 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
62 63
63 $refHistory = new \ReferenceHistory(); 64 $refHistory = new \ReferenceHistory();
64 $refHistory->write(self::$testHistory); 65 $refHistory->write(self::$testHistory);
65 $this->history = new \Shaarli\History(self::$testHistory); 66 $this->history = new History(self::$testHistory);
66 67
67 $this->container = new Container(); 68 $this->container = new Container();
68 $this->container['conf'] = $this->conf; 69 $this->container['conf'] = $this->conf;
69 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); 70 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
70 $this->container['history'] = new \Shaarli\History(self::$testHistory); 71 $this->container['history'] = new History(self::$testHistory);
71 72
72 $this->controller = new Links($this->container); 73 $this->controller = new Links($this->container);
73 74
@@ -119,7 +120,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
119 ); 120 );
120 121
121 $historyEntry = $this->history->getHistory()[0]; 122 $historyEntry = $this->history->getHistory()[0];
122 $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); 123 $this->assertEquals(History::UPDATED, $historyEntry['event']);
123 $this->assertTrue( 124 $this->assertTrue(
124 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] 125 (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
125 ); 126 );
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
4namespace Shaarli\Api\Controllers; 4namespace Shaarli\Api\Controllers;
5 5
6use Shaarli\Bookmark\LinkDB;
6use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
8use Shaarli\History;
7use Slim\Container; 9use Slim\Container;
8use Slim\Http\Environment; 10use Slim\Http\Environment;
9use Slim\Http\Request; 11use Slim\Http\Request;
10use Slim\Http\Response; 12use Slim\Http\Response;
11 13
12class DeleteTagTest extends \PHPUnit_Framework_TestCase 14class 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
3namespace Shaarli\Api\Controllers; 3namespace Shaarli\Api\Controllers;
4 4
5use Shaarli\Bookmark\LinkDB;
5use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
6
7use Slim\Container; 7use Slim\Container;
8use Slim\Http\Environment; 8use Slim\Http\Environment;
9use Slim\Http\Request; 9use 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 */
19class GetTagNameTest extends \PHPUnit_Framework_TestCase 19class 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
2namespace Shaarli\Api\Controllers; 2namespace Shaarli\Api\Controllers;
3 3
4use Shaarli\Bookmark\LinkDB;
4use Shaarli\Config\ConfigManager; 5use Shaarli\Config\ConfigManager;
5
6use Slim\Container; 6use Slim\Container;
7use Slim\Http\Environment; 7use Slim\Http\Environment;
8use Slim\Http\Request; 8use 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 */
18class GetTagsTest extends \PHPUnit_Framework_TestCase 18class 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
4namespace Shaarli\Api\Controllers; 3namespace Shaarli\Api\Controllers;
5 4
6use Shaarli\Api\Exceptions\ApiBadParametersException; 5use Shaarli\Api\Exceptions\ApiBadParametersException;
6use Shaarli\Bookmark\LinkDB;
7use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
8use Shaarli\History;
8use Slim\Container; 9use Slim\Container;
9use Slim\Http\Environment; 10use Slim\Http\Environment;
10use Slim\Http\Request; 11use Slim\Http\Request;
11use Slim\Http\Response; 12use Slim\Http\Response;
12 13
13class PutTagTest extends \PHPUnit_Framework_TestCase 14class 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 );