aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api/controllers/tags/GetTagsTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
commitb6f678a5a1d15acf284ebcec16c905e976671ce1 (patch)
tree33c7da831482ed79c44896ef19c73c72ada84f2e /tests/api/controllers/tags/GetTagsTest.php
parentb14687036b9b800681197f51fdc47e62f0c88e2e (diff)
parent1c1520b6b98ab20201bfe15577782a52320339df (diff)
downloadShaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.gz
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.zst
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.zip
Merge branch 'v0.12' into latest
Diffstat (limited to 'tests/api/controllers/tags/GetTagsTest.php')
-rw-r--r--tests/api/controllers/tags/GetTagsTest.php29
1 files changed, 17 insertions, 12 deletions
diff --git a/tests/api/controllers/tags/GetTagsTest.php b/tests/api/controllers/tags/GetTagsTest.php
index 98628c98..3459fdfa 100644
--- a/tests/api/controllers/tags/GetTagsTest.php
+++ b/tests/api/controllers/tags/GetTagsTest.php
@@ -1,8 +1,10 @@
1<?php 1<?php
2namespace Shaarli\Api\Controllers; 2namespace Shaarli\Api\Controllers;
3 3
4use Shaarli\Bookmark\BookmarkFileService;
4use Shaarli\Bookmark\LinkDB; 5use Shaarli\Bookmark\LinkDB;
5use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
7use Shaarli\History;
6use Slim\Container; 8use Slim\Container;
7use Slim\Http\Environment; 9use Slim\Http\Environment;
8use Slim\Http\Request; 10use Slim\Http\Request;
@@ -15,7 +17,7 @@ use Slim\Http\Response;
15 * 17 *
16 * @package Shaarli\Api\Controllers 18 * @package Shaarli\Api\Controllers
17 */ 19 */
18class GetTagsTest extends \PHPUnit\Framework\TestCase 20class GetTagsTest extends \Shaarli\TestCase
19{ 21{
20 /** 22 /**
21 * @var string datastore to test write operations 23 * @var string datastore to test write operations
@@ -38,9 +40,9 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
38 protected $container; 40 protected $container;
39 41
40 /** 42 /**
41 * @var LinkDB instance. 43 * @var BookmarkFileService instance.
42 */ 44 */
43 protected $linkDB; 45 protected $bookmarkService;
44 46
45 /** 47 /**
46 * @var Tags controller instance. 48 * @var Tags controller instance.
@@ -53,18 +55,21 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
53 const NB_FIELDS_TAG = 2; 55 const NB_FIELDS_TAG = 2;
54 56
55 /** 57 /**
56 * Before every test, instantiate a new Api with its config, plugins and links. 58 * Before every test, instantiate a new Api with its config, plugins and bookmarks.
57 */ 59 */
58 public function setUp() 60 protected function setUp(): void
59 { 61 {
60 $this->conf = new ConfigManager('tests/utils/config/configJson'); 62 $this->conf = new ConfigManager('tests/utils/config/configJson');
63 $this->conf->set('resource.datastore', self::$testDatastore);
61 $this->refDB = new \ReferenceLinkDB(); 64 $this->refDB = new \ReferenceLinkDB();
62 $this->refDB->write(self::$testDatastore); 65 $this->refDB->write(self::$testDatastore);
66 $history = new History('sandbox/history.php');
67
68 $this->bookmarkService = new BookmarkFileService($this->conf, $history, true);
63 69
64 $this->container = new Container(); 70 $this->container = new Container();
65 $this->container['conf'] = $this->conf; 71 $this->container['conf'] = $this->conf;
66 $this->linkDB = new LinkDB(self::$testDatastore, true, false); 72 $this->container['db'] = $this->bookmarkService;
67 $this->container['db'] = $this->linkDB;
68 $this->container['history'] = null; 73 $this->container['history'] = null;
69 74
70 $this->controller = new Tags($this->container); 75 $this->controller = new Tags($this->container);
@@ -73,7 +78,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
73 /** 78 /**
74 * After every test, remove the test datastore. 79 * After every test, remove the test datastore.
75 */ 80 */
76 public function tearDown() 81 protected function tearDown(): void
77 { 82 {
78 @unlink(self::$testDatastore); 83 @unlink(self::$testDatastore);
79 } 84 }
@@ -83,7 +88,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
83 */ 88 */
84 public function testGetTagsAll() 89 public function testGetTagsAll()
85 { 90 {
86 $tags = $this->linkDB->linksCountPerTag(); 91 $tags = $this->bookmarkService->bookmarksCountPerTag();
87 $env = Environment::mock([ 92 $env = Environment::mock([
88 'REQUEST_METHOD' => 'GET', 93 'REQUEST_METHOD' => 'GET',
89 ]); 94 ]);
@@ -136,7 +141,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
136 */ 141 */
137 public function testGetTagsLimitAll() 142 public function testGetTagsLimitAll()
138 { 143 {
139 $tags = $this->linkDB->linksCountPerTag(); 144 $tags = $this->bookmarkService->bookmarksCountPerTag();
140 $env = Environment::mock([ 145 $env = Environment::mock([
141 'REQUEST_METHOD' => 'GET', 146 'REQUEST_METHOD' => 'GET',
142 'QUERY_STRING' => 'limit=all' 147 'QUERY_STRING' => 'limit=all'
@@ -170,7 +175,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
170 */ 175 */
171 public function testGetTagsVisibilityPrivate() 176 public function testGetTagsVisibilityPrivate()
172 { 177 {
173 $tags = $this->linkDB->linksCountPerTag([], 'private'); 178 $tags = $this->bookmarkService->bookmarksCountPerTag([], 'private');
174 $env = Environment::mock([ 179 $env = Environment::mock([
175 'REQUEST_METHOD' => 'GET', 180 'REQUEST_METHOD' => 'GET',
176 'QUERY_STRING' => 'visibility=private' 181 'QUERY_STRING' => 'visibility=private'
@@ -190,7 +195,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
190 */ 195 */
191 public function testGetTagsVisibilityPublic() 196 public function testGetTagsVisibilityPublic()
192 { 197 {
193 $tags = $this->linkDB->linksCountPerTag([], 'public'); 198 $tags = $this->bookmarkService->bookmarksCountPerTag([], 'public');
194 $env = Environment::mock( 199 $env = Environment::mock(
195 [ 200 [
196 'REQUEST_METHOD' => 'GET', 201 'REQUEST_METHOD' => 'GET',