diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-01-17 21:34:12 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-01-18 09:56:32 +0100 |
commit | e26e2060f5470ce8bf4c5973284bae07b8af170a (patch) | |
tree | adf8512f93f5559ba87d0c9931969ae4ebea7133 /tests/api/controllers/links/GetLinkIdTest.php | |
parent | cf92b4dd1521241eefc58eaf6dcd202cd83969d8 (diff) | |
download | Shaarli-e26e2060f5470ce8bf4c5973284bae07b8af170a.tar.gz Shaarli-e26e2060f5470ce8bf4c5973284bae07b8af170a.tar.zst Shaarli-e26e2060f5470ce8bf4c5973284bae07b8af170a.zip |
Add and update unit test for the new system (Bookmark + Service)
See #1307
Diffstat (limited to 'tests/api/controllers/links/GetLinkIdTest.php')
-rw-r--r-- | tests/api/controllers/links/GetLinkIdTest.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php index cb9b7f6a..c26411ac 100644 --- a/tests/api/controllers/links/GetLinkIdTest.php +++ b/tests/api/controllers/links/GetLinkIdTest.php | |||
@@ -2,7 +2,10 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Api\Controllers; | 3 | namespace Shaarli\Api\Controllers; |
4 | 4 | ||
5 | use Shaarli\Bookmark\Bookmark; | ||
6 | use Shaarli\Bookmark\BookmarkFileService; | ||
5 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
8 | use Shaarli\History; | ||
6 | use Slim\Container; | 9 | use Slim\Container; |
7 | use Slim\Http\Environment; | 10 | use Slim\Http\Environment; |
8 | use Slim\Http\Request; | 11 | use Slim\Http\Request; |
@@ -50,17 +53,19 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase | |||
50 | const NB_FIELDS_LINK = 9; | 53 | const NB_FIELDS_LINK = 9; |
51 | 54 | ||
52 | /** | 55 | /** |
53 | * Before each test, instantiate a new Api with its config, plugins and links. | 56 | * Before each test, instantiate a new Api with its config, plugins and bookmarks. |
54 | */ | 57 | */ |
55 | public function setUp() | 58 | public function setUp() |
56 | { | 59 | { |
57 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | 60 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
61 | $this->conf->set('resource.datastore', self::$testDatastore); | ||
58 | $this->refDB = new \ReferenceLinkDB(); | 62 | $this->refDB = new \ReferenceLinkDB(); |
59 | $this->refDB->write(self::$testDatastore); | 63 | $this->refDB->write(self::$testDatastore); |
64 | $history = new History('sandbox/history.php'); | ||
60 | 65 | ||
61 | $this->container = new Container(); | 66 | $this->container = new Container(); |
62 | $this->container['conf'] = $this->conf; | 67 | $this->container['conf'] = $this->conf; |
63 | $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 68 | $this->container['db'] = new BookmarkFileService($this->conf, $history, true); |
64 | $this->container['history'] = null; | 69 | $this->container['history'] = null; |
65 | 70 | ||
66 | $this->controller = new Links($this->container); | 71 | $this->controller = new Links($this->container); |
@@ -107,7 +112,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase | |||
107 | $this->assertEquals('sTuff', $data['tags'][0]); | 112 | $this->assertEquals('sTuff', $data['tags'][0]); |
108 | $this->assertEquals(false, $data['private']); | 113 | $this->assertEquals(false, $data['private']); |
109 | $this->assertEquals( | 114 | $this->assertEquals( |
110 | \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), | 115 | \DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), |
111 | $data['created'] | 116 | $data['created'] |
112 | ); | 117 | ); |
113 | $this->assertEmpty($data['updated']); | 118 | $this->assertEmpty($data['updated']); |