aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api/controllers/tags/DeleteTagTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api/controllers/tags/DeleteTagTest.php')
-rw-r--r--tests/api/controllers/tags/DeleteTagTest.php22
1 files changed, 12 insertions, 10 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 );