aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api/controllers/tags
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api/controllers/tags')
-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
4 files changed, 28 insertions, 25 deletions
diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php
index e0787ce2..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 \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 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 \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;
@@ -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 \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(\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(\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 \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(\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 afac228e..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 \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 3fab31b0..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 \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 \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 38017243..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 \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 \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 \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 \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(\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(\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 );