X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fapi%2Fcontrollers%2Flinks%2FGetLinksTest.php;h=3c96673282d4b657c7866fea8f7509334db2b1ba;hb=refs%2Fpull%2F1698%2Fhead;hp=711a315221b84d85d5829413866caa2411d5de1b;hpb=dea72c711ff740b3b829d238fcf85648465143a0;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php index 711a3152..3c966732 100644 --- a/tests/api/controllers/links/GetLinksTest.php +++ b/tests/api/controllers/links/GetLinksTest.php @@ -1,8 +1,13 @@ 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 LinkDB(self::$testDatastore, true, false); + $pluginManager = new PluginManager($this->conf); + $this->container['db'] = new BookmarkFileService( + $this->conf, + $pluginManager, + $history, + $mutex, + true + ); $this->container['history'] = null; $this->controller = new Links($this->container); @@ -69,13 +84,13 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase /** * After every test, remove the test datastore. */ - public function tearDown() + protected function tearDown(): void { @unlink(self::$testDatastore); } /** - * Test basic getLinks service: returns all links. + * Test basic getLinks service: returns all bookmarks. */ public function testGetLinks() { @@ -104,7 +119,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase // Check first element fields $first = $data[2]; - $this->assertEquals('http://domain.tld/?WDWyig', $first['url']); + $this->assertEquals('http://domain.tld/shaare/WDWyig', $first['url']); $this->assertEquals('WDWyig', $first['shorturl']); $this->assertEquals('Link title: @website', $first['title']); $this->assertEquals( @@ -114,7 +129,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase $this->assertEquals('sTuff', $first['tags'][0]); $this->assertEquals(false, $first['private']); $this->assertEquals( - \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), + \DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), $first['created'] ); $this->assertEmpty($first['updated']); @@ -125,7 +140,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase // Update date $this->assertEquals( - \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), + \DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), $link['updated'] ); } @@ -391,7 +406,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase $response = $this->controller->getLinks($request, new Response()); $this->assertEquals(200, $response->getStatusCode()); $data = json_decode((string) $response->getBody(), true); - $this->assertEquals(4, count($data)); + $this->assertEquals(5, count($data)); $this->assertEquals(6, $data[0]['id']); // wildcard: placeholder at the middle