From e26e2060f5470ce8bf4c5973284bae07b8af170a Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 17 Jan 2020 21:34:12 +0100 Subject: Add and update unit test for the new system (Bookmark + Service) See #1307 --- tests/api/controllers/links/GetLinkIdTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/api/controllers/links/GetLinkIdTest.php') 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 @@ namespace Shaarli\Api\Controllers; +use Shaarli\Bookmark\Bookmark; +use Shaarli\Bookmark\BookmarkFileService; use Shaarli\Config\ConfigManager; +use Shaarli\History; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -50,17 +53,19 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase const NB_FIELDS_LINK = 9; /** - * Before each test, instantiate a new Api with its config, plugins and links. + * Before each test, instantiate a new Api with its config, plugins and bookmarks. */ public function setUp() { $this->conf = new ConfigManager('tests/utils/config/configJson'); + $this->conf->set('resource.datastore', self::$testDatastore); $this->refDB = new \ReferenceLinkDB(); $this->refDB->write(self::$testDatastore); + $history = new History('sandbox/history.php'); $this->container = new Container(); $this->container['conf'] = $this->conf; - $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); + $this->container['db'] = new BookmarkFileService($this->conf, $history, true); $this->container['history'] = null; $this->controller = new Links($this->container); @@ -107,7 +112,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase $this->assertEquals('sTuff', $data['tags'][0]); $this->assertEquals(false, $data['private']); $this->assertEquals( - \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), + \DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), $data['created'] ); $this->assertEmpty($data['updated']); -- cgit v1.2.3