aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/ApiMiddlewareTest.php2
-rw-r--r--tests/api/controllers/info/InfoTest.php11
-rw-r--r--tests/api/controllers/links/DeleteLinkTest.php21
-rw-r--r--tests/api/controllers/links/GetLinkIdTest.php10
-rw-r--r--tests/api/controllers/links/GetLinksTest.php10
-rw-r--r--tests/api/controllers/links/PostLinkTest.php11
-rw-r--r--tests/api/controllers/links/PutLinkTest.php11
-rw-r--r--tests/api/controllers/tags/DeleteTagTest.php29
-rw-r--r--tests/api/controllers/tags/GetTagNameTest.php13
-rw-r--r--tests/api/controllers/tags/GetTagsTest.php15
-rw-r--r--tests/api/controllers/tags/PutTagTest.php13
11 files changed, 128 insertions, 18 deletions
diff --git a/tests/api/ApiMiddlewareTest.php b/tests/api/ApiMiddlewareTest.php
index 86700840..2afac28b 100644
--- a/tests/api/ApiMiddlewareTest.php
+++ b/tests/api/ApiMiddlewareTest.php
@@ -3,6 +3,7 @@ namespace Shaarli\Api;
3 3
4use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
5use Shaarli\History; 5use Shaarli\History;
6use Shaarli\Plugin\PluginManager;
6use Slim\Container; 7use Slim\Container;
7use Slim\Http\Environment; 8use Slim\Http\Environment;
8use Slim\Http\Request; 9use Slim\Http\Request;
@@ -56,6 +57,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
56 $this->container = new Container(); 57 $this->container = new Container();
57 $this->container['conf'] = $this->conf; 58 $this->container['conf'] = $this->conf;
58 $this->container['history'] = $history; 59 $this->container['history'] = $history;
60 $this->container['pluginManager'] = new PluginManager($this->conf);
59 } 61 }
60 62
61 /** 63 /**
diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php
index 10b29ab2..2428ca43 100644
--- a/tests/api/controllers/info/InfoTest.php
+++ b/tests/api/controllers/info/InfoTest.php
@@ -5,6 +5,7 @@ use malkusch\lock\mutex\NoMutex;
5use Shaarli\Bookmark\BookmarkFileService; 5use Shaarli\Bookmark\BookmarkFileService;
6use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
7use Shaarli\History; 7use Shaarli\History;
8use Shaarli\Plugin\PluginManager;
8use Shaarli\TestCase; 9use Shaarli\TestCase;
9use Slim\Container; 10use Slim\Container;
10use Slim\Http\Environment; 11use Slim\Http\Environment;
@@ -55,12 +56,18 @@ class InfoTest extends TestCase
55 $this->conf->set('resource.datastore', self::$testDatastore); 56 $this->conf->set('resource.datastore', self::$testDatastore);
56 $this->refDB = new \ReferenceLinkDB(); 57 $this->refDB = new \ReferenceLinkDB();
57 $this->refDB->write(self::$testDatastore); 58 $this->refDB->write(self::$testDatastore);
58 59 $this->pluginManager = new PluginManager($this->conf);
59 $history = new History('sandbox/history.php'); 60 $history = new History('sandbox/history.php');
60 61
61 $this->container = new Container(); 62 $this->container = new Container();
62 $this->container['conf'] = $this->conf; 63 $this->container['conf'] = $this->conf;
63 $this->container['db'] = new BookmarkFileService($this->conf, $history, $mutex, true); 64 $this->container['db'] = new BookmarkFileService(
65 $this->conf,
66 $this->pluginManager,
67 $history,
68 $mutex,
69 true
70 );
64 $this->container['history'] = null; 71 $this->container['history'] = null;
65 72
66 $this->controller = new Info($this->container); 73 $this->controller = new Info($this->container);
diff --git a/tests/api/controllers/links/DeleteLinkTest.php b/tests/api/controllers/links/DeleteLinkTest.php
index 805c9be3..dc2cf917 100644
--- a/tests/api/controllers/links/DeleteLinkTest.php
+++ b/tests/api/controllers/links/DeleteLinkTest.php
@@ -7,6 +7,7 @@ use malkusch\lock\mutex\NoMutex;
7use Shaarli\Bookmark\BookmarkFileService; 7use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\History; 9use Shaarli\History;
10use Shaarli\Plugin\PluginManager;
10use Slim\Container; 11use Slim\Container;
11use Slim\Http\Environment; 12use Slim\Http\Environment;
12use Slim\Http\Request; 13use Slim\Http\Request;
@@ -57,6 +58,9 @@ class DeleteLinkTest extends \Shaarli\TestCase
57 /** @var NoMutex */ 58 /** @var NoMutex */
58 protected $mutex; 59 protected $mutex;
59 60
61 /** @var PluginManager */
62 protected $pluginManager;
63
60 /** 64 /**
61 * Before each test, instantiate a new Api with its config, plugins and bookmarks. 65 * Before each test, instantiate a new Api with its config, plugins and bookmarks.
62 */ 66 */
@@ -70,7 +74,14 @@ class DeleteLinkTest extends \Shaarli\TestCase
70 $refHistory = new \ReferenceHistory(); 74 $refHistory = new \ReferenceHistory();
71 $refHistory->write(self::$testHistory); 75 $refHistory->write(self::$testHistory);
72 $this->history = new History(self::$testHistory); 76 $this->history = new History(self::$testHistory);
73 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); 77 $this->pluginManager = new PluginManager($this->conf);
78 $this->bookmarkService = new BookmarkFileService(
79 $this->conf,
80 $this->pluginManager,
81 $this->history,
82 $this->mutex,
83 true
84 );
74 85
75 $this->container = new Container(); 86 $this->container = new Container();
76 $this->container['conf'] = $this->conf; 87 $this->container['conf'] = $this->conf;
@@ -105,7 +116,13 @@ class DeleteLinkTest extends \Shaarli\TestCase
105 $this->assertEquals(204, $response->getStatusCode()); 116 $this->assertEquals(204, $response->getStatusCode());
106 $this->assertEmpty((string) $response->getBody()); 117 $this->assertEmpty((string) $response->getBody());
107 118
108 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); 119 $this->bookmarkService = new BookmarkFileService(
120 $this->conf,
121 $this->pluginManager,
122 $this->history,
123 $this->mutex,
124 true
125 );
109 $this->assertFalse($this->bookmarkService->exists($id)); 126 $this->assertFalse($this->bookmarkService->exists($id));
110 127
111 $historyEntry = $this->history->getHistory()[0]; 128 $historyEntry = $this->history->getHistory()[0];
diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php
index 1ec56ef3..c93a3b4b 100644
--- a/tests/api/controllers/links/GetLinkIdTest.php
+++ b/tests/api/controllers/links/GetLinkIdTest.php
@@ -7,6 +7,7 @@ use Shaarli\Bookmark\Bookmark;
7use Shaarli\Bookmark\BookmarkFileService; 7use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\History; 9use Shaarli\History;
10use Shaarli\Plugin\PluginManager;
10use Slim\Container; 11use Slim\Container;
11use Slim\Http\Environment; 12use Slim\Http\Environment;
12use Slim\Http\Request; 13use Slim\Http\Request;
@@ -67,7 +68,14 @@ class GetLinkIdTest extends \Shaarli\TestCase
67 68
68 $this->container = new Container(); 69 $this->container = new Container();
69 $this->container['conf'] = $this->conf; 70 $this->container['conf'] = $this->conf;
70 $this->container['db'] = new BookmarkFileService($this->conf, $history, $mutex, true); 71 $pluginManager = new PluginManager($this->conf);
72 $this->container['db'] = new BookmarkFileService(
73 $this->conf,
74 $pluginManager,
75 $history,
76 $mutex,
77 true
78 );
71 $this->container['history'] = null; 79 $this->container['history'] = null;
72 80
73 $this->controller = new Links($this->container); 81 $this->controller = new Links($this->container);
diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php
index b1c46ee2..3c966732 100644
--- a/tests/api/controllers/links/GetLinksTest.php
+++ b/tests/api/controllers/links/GetLinksTest.php
@@ -7,6 +7,7 @@ use Shaarli\Bookmark\BookmarkFileService;
7use Shaarli\Bookmark\LinkDB; 7use Shaarli\Bookmark\LinkDB;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\History; 9use Shaarli\History;
10use Shaarli\Plugin\PluginManager;
10use Slim\Container; 11use Slim\Container;
11use Slim\Http\Environment; 12use Slim\Http\Environment;
12use Slim\Http\Request; 13use Slim\Http\Request;
@@ -67,7 +68,14 @@ class GetLinksTest extends \Shaarli\TestCase
67 68
68 $this->container = new Container(); 69 $this->container = new Container();
69 $this->container['conf'] = $this->conf; 70 $this->container['conf'] = $this->conf;
70 $this->container['db'] = new BookmarkFileService($this->conf, $history, $mutex, true); 71 $pluginManager = new PluginManager($this->conf);
72 $this->container['db'] = new BookmarkFileService(
73 $this->conf,
74 $pluginManager,
75 $history,
76 $mutex,
77 true
78 );
71 $this->container['history'] = null; 79 $this->container['history'] = null;
72 80
73 $this->controller = new Links($this->container); 81 $this->controller = new Links($this->container);
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php
index f755e2d2..a54e4a16 100644
--- a/tests/api/controllers/links/PostLinkTest.php
+++ b/tests/api/controllers/links/PostLinkTest.php
@@ -7,6 +7,7 @@ use Shaarli\Bookmark\Bookmark;
7use Shaarli\Bookmark\BookmarkFileService; 7use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\History; 9use Shaarli\History;
10use Shaarli\Plugin\PluginManager;
10use Shaarli\TestCase; 11use Shaarli\TestCase;
11use Slim\Container; 12use Slim\Container;
12use Slim\Http\Environment; 13use Slim\Http\Environment;
@@ -81,8 +82,14 @@ class PostLinkTest extends TestCase
81 $refHistory = new \ReferenceHistory(); 82 $refHistory = new \ReferenceHistory();
82 $refHistory->write(self::$testHistory); 83 $refHistory->write(self::$testHistory);
83 $this->history = new History(self::$testHistory); 84 $this->history = new History(self::$testHistory);
84 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true); 85 $pluginManager = new PluginManager($this->conf);
85 86 $this->bookmarkService = new BookmarkFileService(
87 $this->conf,
88 $pluginManager,
89 $this->history,
90 $mutex,
91 true
92 );
86 $this->container = new Container(); 93 $this->container = new Container();
87 $this->container['conf'] = $this->conf; 94 $this->container['conf'] = $this->conf;
88 $this->container['db'] = $this->bookmarkService; 95 $this->container['db'] = $this->bookmarkService;
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php
index fe24f2eb..ed14d5f8 100644
--- a/tests/api/controllers/links/PutLinkTest.php
+++ b/tests/api/controllers/links/PutLinkTest.php
@@ -8,6 +8,7 @@ use Shaarli\Bookmark\Bookmark;
8use Shaarli\Bookmark\BookmarkFileService; 8use Shaarli\Bookmark\BookmarkFileService;
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\History; 10use Shaarli\History;
11use Shaarli\Plugin\PluginManager;
11use Slim\Container; 12use Slim\Container;
12use Slim\Http\Environment; 13use Slim\Http\Environment;
13use Slim\Http\Request; 14use Slim\Http\Request;
@@ -73,8 +74,14 @@ class PutLinkTest extends \Shaarli\TestCase
73 $refHistory = new \ReferenceHistory(); 74 $refHistory = new \ReferenceHistory();
74 $refHistory->write(self::$testHistory); 75 $refHistory->write(self::$testHistory);
75 $this->history = new History(self::$testHistory); 76 $this->history = new History(self::$testHistory);
76 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true); 77 $pluginManager = new PluginManager($this->conf);
77 78 $this->bookmarkService = new BookmarkFileService(
79 $this->conf,
80 $pluginManager,
81 $this->history,
82 $mutex,
83 true
84 );
78 $this->container = new Container(); 85 $this->container = new Container();
79 $this->container['conf'] = $this->conf; 86 $this->container['conf'] = $this->conf;
80 $this->container['db'] = $this->bookmarkService; 87 $this->container['db'] = $this->bookmarkService;
diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php
index 37f07229..c0f8a6a9 100644
--- a/tests/api/controllers/tags/DeleteTagTest.php
+++ b/tests/api/controllers/tags/DeleteTagTest.php
@@ -8,6 +8,7 @@ use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Bookmark\LinkDB; 8use Shaarli\Bookmark\LinkDB;
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\History; 10use Shaarli\History;
11use Shaarli\Plugin\PluginManager;
11use Slim\Container; 12use Slim\Container;
12use Slim\Http\Environment; 13use Slim\Http\Environment;
13use Slim\Http\Request; 14use Slim\Http\Request;
@@ -55,6 +56,9 @@ class DeleteTagTest extends \Shaarli\TestCase
55 */ 56 */
56 protected $controller; 57 protected $controller;
57 58
59 /** @var PluginManager */
60 protected $pluginManager;
61
58 /** @var NoMutex */ 62 /** @var NoMutex */
59 protected $mutex; 63 protected $mutex;
60 64
@@ -71,7 +75,14 @@ class DeleteTagTest extends \Shaarli\TestCase
71 $refHistory = new \ReferenceHistory(); 75 $refHistory = new \ReferenceHistory();
72 $refHistory->write(self::$testHistory); 76 $refHistory->write(self::$testHistory);
73 $this->history = new History(self::$testHistory); 77 $this->history = new History(self::$testHistory);
74 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); 78 $this->pluginManager = new PluginManager($this->conf);
79 $this->bookmarkService = new BookmarkFileService(
80 $this->conf,
81 $this->pluginManager,
82 $this->history,
83 $this->mutex,
84 true
85 );
75 86
76 $this->container = new Container(); 87 $this->container = new Container();
77 $this->container['conf'] = $this->conf; 88 $this->container['conf'] = $this->conf;
@@ -107,7 +118,13 @@ class DeleteTagTest extends \Shaarli\TestCase
107 $this->assertEquals(204, $response->getStatusCode()); 118 $this->assertEquals(204, $response->getStatusCode());
108 $this->assertEmpty((string) $response->getBody()); 119 $this->assertEmpty((string) $response->getBody());
109 120
110 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); 121 $this->bookmarkService = new BookmarkFileService(
122 $this->conf,
123 $this->pluginManager,
124 $this->history,
125 $this->mutex,
126 true
127 );
111 $tags = $this->bookmarkService->bookmarksCountPerTag(); 128 $tags = $this->bookmarkService->bookmarksCountPerTag();
112 $this->assertFalse(isset($tags[$tagName])); 129 $this->assertFalse(isset($tags[$tagName]));
113 130
@@ -141,7 +158,13 @@ class DeleteTagTest extends \Shaarli\TestCase
141 $this->assertEquals(204, $response->getStatusCode()); 158 $this->assertEquals(204, $response->getStatusCode());
142 $this->assertEmpty((string) $response->getBody()); 159 $this->assertEmpty((string) $response->getBody());
143 160
144 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $this->mutex, true); 161 $this->bookmarkService = new BookmarkFileService(
162 $this->conf,
163 $this->pluginManager,
164 $this->history,
165 $this->mutex,
166 true
167 );
145 $tags = $this->bookmarkService->bookmarksCountPerTag(); 168 $tags = $this->bookmarkService->bookmarksCountPerTag();
146 $this->assertFalse(isset($tags[$tagName])); 169 $this->assertFalse(isset($tags[$tagName]));
147 $this->assertTrue($tags[strtolower($tagName)] > 0); 170 $this->assertTrue($tags[strtolower($tagName)] > 0);
diff --git a/tests/api/controllers/tags/GetTagNameTest.php b/tests/api/controllers/tags/GetTagNameTest.php
index 878de5a4..0ad71495 100644
--- a/tests/api/controllers/tags/GetTagNameTest.php
+++ b/tests/api/controllers/tags/GetTagNameTest.php
@@ -7,6 +7,7 @@ use Shaarli\Bookmark\BookmarkFileService;
7use Shaarli\Bookmark\LinkDB; 7use Shaarli\Bookmark\LinkDB;
8use Shaarli\Config\ConfigManager; 8use Shaarli\Config\ConfigManager;
9use Shaarli\History; 9use Shaarli\History;
10use Shaarli\Plugin\PluginManager;
10use Slim\Container; 11use Slim\Container;
11use Slim\Http\Environment; 12use Slim\Http\Environment;
12use Slim\Http\Request; 13use Slim\Http\Request;
@@ -46,6 +47,9 @@ class GetTagNameTest extends \Shaarli\TestCase
46 */ 47 */
47 protected $controller; 48 protected $controller;
48 49
50 /** @var PluginManager */
51 protected $pluginManager;
52
49 /** 53 /**
50 * Number of JSON fields per link. 54 * Number of JSON fields per link.
51 */ 55 */
@@ -65,7 +69,14 @@ class GetTagNameTest extends \Shaarli\TestCase
65 69
66 $this->container = new Container(); 70 $this->container = new Container();
67 $this->container['conf'] = $this->conf; 71 $this->container['conf'] = $this->conf;
68 $this->container['db'] = new BookmarkFileService($this->conf, $history, $mutex, true); 72 $this->pluginManager = new PluginManager($this->conf);
73 $this->container['db'] = new BookmarkFileService(
74 $this->conf,
75 $this->pluginManager,
76 $history,
77 $mutex,
78 true
79 );
69 $this->container['history'] = null; 80 $this->container['history'] = null;
70 81
71 $this->controller = new Tags($this->container); 82 $this->controller = new Tags($this->container);
diff --git a/tests/api/controllers/tags/GetTagsTest.php b/tests/api/controllers/tags/GetTagsTest.php
index b565a8c4..a4b62c51 100644
--- a/tests/api/controllers/tags/GetTagsTest.php
+++ b/tests/api/controllers/tags/GetTagsTest.php
@@ -6,6 +6,7 @@ use Shaarli\Bookmark\BookmarkFileService;
6use Shaarli\Bookmark\LinkDB; 6use Shaarli\Bookmark\LinkDB;
7use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
8use Shaarli\History; 8use Shaarli\History;
9use Shaarli\Plugin\PluginManager;
9use Slim\Container; 10use Slim\Container;
10use Slim\Http\Environment; 11use Slim\Http\Environment;
11use Slim\Http\Request; 12use Slim\Http\Request;
@@ -50,6 +51,9 @@ class GetTagsTest extends \Shaarli\TestCase
50 */ 51 */
51 protected $controller; 52 protected $controller;
52 53
54 /** @var PluginManager */
55 protected $pluginManager;
56
53 /** 57 /**
54 * Number of JSON field per link. 58 * Number of JSON field per link.
55 */ 59 */
@@ -66,9 +70,14 @@ class GetTagsTest extends \Shaarli\TestCase
66 $this->refDB = new \ReferenceLinkDB(); 70 $this->refDB = new \ReferenceLinkDB();
67 $this->refDB->write(self::$testDatastore); 71 $this->refDB->write(self::$testDatastore);
68 $history = new History('sandbox/history.php'); 72 $history = new History('sandbox/history.php');
69 73 $this->pluginManager = new PluginManager($this->conf);
70 $this->bookmarkService = new BookmarkFileService($this->conf, $history, $mutex, true); 74 $this->bookmarkService = new BookmarkFileService(
71 75 $this->conf,
76 $this->pluginManager,
77 $history,
78 $mutex,
79 true
80 );
72 $this->container = new Container(); 81 $this->container = new Container();
73 $this->container['conf'] = $this->conf; 82 $this->container['conf'] = $this->conf;
74 $this->container['db'] = $this->bookmarkService; 83 $this->container['db'] = $this->bookmarkService;
diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php
index c73f6d3b..045473e6 100644
--- a/tests/api/controllers/tags/PutTagTest.php
+++ b/tests/api/controllers/tags/PutTagTest.php
@@ -8,6 +8,7 @@ use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Bookmark\LinkDB; 8use Shaarli\Bookmark\LinkDB;
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\History; 10use Shaarli\History;
11use Shaarli\Plugin\PluginManager;
11use Slim\Container; 12use Slim\Container;
12use Slim\Http\Environment; 13use Slim\Http\Environment;
13use Slim\Http\Request; 14use Slim\Http\Request;
@@ -55,6 +56,9 @@ class PutTagTest extends \Shaarli\TestCase
55 */ 56 */
56 protected $controller; 57 protected $controller;
57 58
59 /** @var PluginManager */
60 protected $pluginManager;
61
58 /** 62 /**
59 * Number of JSON field per link. 63 * Number of JSON field per link.
60 */ 64 */
@@ -73,7 +77,14 @@ class PutTagTest extends \Shaarli\TestCase
73 $refHistory = new \ReferenceHistory(); 77 $refHistory = new \ReferenceHistory();
74 $refHistory->write(self::$testHistory); 78 $refHistory->write(self::$testHistory);
75 $this->history = new History(self::$testHistory); 79 $this->history = new History(self::$testHistory);
76 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, $mutex, true); 80 $this->pluginManager = new PluginManager($this->conf);
81 $this->bookmarkService = new BookmarkFileService(
82 $this->conf,
83 $this->pluginManager,
84 $this->history,
85 $mutex,
86 true
87 );
77 88
78 $this->container = new Container(); 89 $this->container = new Container();
79 $this->container['conf'] = $this->conf; 90 $this->container['conf'] = $this->conf;