aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/api/controllers/tags/GetTagNameTest.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/GetTagNameTest.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/GetTagNameTest.php')
-rw-r--r--tests/api/controllers/tags/GetTagNameTest.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/api/controllers/tags/GetTagNameTest.php b/tests/api/controllers/tags/GetTagNameTest.php
index a2525c17..9c05954b 100644
--- a/tests/api/controllers/tags/GetTagNameTest.php
+++ b/tests/api/controllers/tags/GetTagNameTest.php
@@ -2,8 +2,10 @@
2 2
3namespace Shaarli\Api\Controllers; 3namespace Shaarli\Api\Controllers;
4 4
5use Shaarli\Bookmark\BookmarkFileService;
5use Shaarli\Bookmark\LinkDB; 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;
@@ -16,7 +18,7 @@ use Slim\Http\Response;
16 * 18 *
17 * @package Shaarli\Api\Controllers 19 * @package Shaarli\Api\Controllers
18 */ 20 */
19class GetTagNameTest extends \PHPUnit\Framework\TestCase 21class GetTagNameTest extends \Shaarli\TestCase
20{ 22{
21 /** 23 /**
22 * @var string datastore to test write operations 24 * @var string datastore to test write operations
@@ -49,17 +51,19 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase
49 const NB_FIELDS_TAG = 2; 51 const NB_FIELDS_TAG = 2;
50 52
51 /** 53 /**
52 * Before each test, instantiate a new Api with its config, plugins and links. 54 * Before each test, instantiate a new Api with its config, plugins and bookmarks.
53 */ 55 */
54 public function setUp() 56 protected function setUp(): void
55 { 57 {
56 $this->conf = new ConfigManager('tests/utils/config/configJson'); 58 $this->conf = new ConfigManager('tests/utils/config/configJson');
59 $this->conf->set('resource.datastore', self::$testDatastore);
57 $this->refDB = new \ReferenceLinkDB(); 60 $this->refDB = new \ReferenceLinkDB();
58 $this->refDB->write(self::$testDatastore); 61 $this->refDB->write(self::$testDatastore);
62 $history = new History('sandbox/history.php');
59 63
60 $this->container = new Container(); 64 $this->container = new Container();
61 $this->container['conf'] = $this->conf; 65 $this->container['conf'] = $this->conf;
62 $this->container['db'] = new LinkDB(self::$testDatastore, true, false); 66 $this->container['db'] = new BookmarkFileService($this->conf, $history, true);
63 $this->container['history'] = null; 67 $this->container['history'] = null;
64 68
65 $this->controller = new Tags($this->container); 69 $this->controller = new Tags($this->container);
@@ -68,7 +72,7 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase
68 /** 72 /**
69 * After each test, remove the test datastore. 73 * After each test, remove the test datastore.
70 */ 74 */
71 public function tearDown() 75 protected function tearDown(): void
72 { 76 {
73 @unlink(self::$testDatastore); 77 @unlink(self::$testDatastore);
74 } 78 }
@@ -113,12 +117,12 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase
113 117
114 /** 118 /**
115 * Test basic getTag service: get non existent tag => ApiTagNotFoundException. 119 * Test basic getTag service: get non existent tag => ApiTagNotFoundException.
116 *
117 * @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException
118 * @expectedExceptionMessage Tag not found
119 */ 120 */
120 public function testGetTag404() 121 public function testGetTag404()
121 { 122 {
123 $this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class);
124 $this->expectExceptionMessage('Tag not found');
125
122 $env = Environment::mock([ 126 $env = Environment::mock([
123 'REQUEST_METHOD' => 'GET', 127 'REQUEST_METHOD' => 'GET',
124 ]); 128 ]);