X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fapi%2Fcontrollers%2Ftags%2FPutTagTest.php;h=2a3cc15a0d05e1ff5c21f2c6837cc222572cdbda;hb=3fb29fdda04ca86e04422d49b86cf646d53c4f9d;hp=d8c0fec86fe5b7c120e57b00a18c519a274baeee;hpb=f24896b237e40718fb6eaa2869592eb0855a47fd;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php index d8c0fec8..2a3cc15a 100644 --- a/tests/api/controllers/tags/PutTagTest.php +++ b/tests/api/controllers/tags/PutTagTest.php @@ -1,16 +1,18 @@ conf = new ConfigManager('tests/utils/config/configJson.json.php'); + $this->conf = new ConfigManager('tests/utils/config/configJson'); + $this->conf->set('resource.datastore', self::$testDatastore); $this->refDB = new \ReferenceLinkDB(); $this->refDB->write(self::$testDatastore); - $refHistory = new \ReferenceHistory(); $refHistory->write(self::$testHistory); - $this->history = new \Shaarli\History(self::$testHistory); + $this->history = new History(self::$testHistory); + $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); $this->container = new Container(); $this->container['conf'] = $this->conf; - $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); - $this->container['db'] = $this->linkDB; + $this->container['db'] = $this->bookmarkService; $this->container['history'] = $this->history; $this->controller = new Tags($this->container); @@ -108,17 +110,17 @@ class PutTagTest extends \PHPUnit_Framework_TestCase $this->assertEquals($newName, $data['name']); $this->assertEquals(2, $data['occurrences']); - $tags = $this->linkDB->linksCountPerTag(); + $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertNotTrue(isset($tags[$tagName])); $this->assertEquals(2, $tags[$newName]); $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); $historyEntry = $this->history->getHistory()[1]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); @@ -132,7 +134,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase $tagName = 'gnu'; $newName = 'w3c'; - $tags = $this->linkDB->linksCountPerTag(); + $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertEquals(1, $tags[$newName]); $this->assertEquals(2, $tags[$tagName]); @@ -150,7 +152,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase $this->assertEquals($newName, $data['name']); $this->assertEquals(3, $data['occurrences']); - $tags = $this->linkDB->linksCountPerTag(); + $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertNotTrue(isset($tags[$tagName])); $this->assertEquals(3, $tags[$newName]); } @@ -166,7 +168,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase $tagName = 'gnu'; $newName = ''; - $tags = $this->linkDB->linksCountPerTag(); + $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertEquals(2, $tags[$tagName]); $env = Environment::mock([ @@ -184,7 +186,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase try { $this->controller->putTag($request, new Response(), ['tagName' => $tagName]); } catch (ApiBadParametersException $e) { - $tags = $this->linkDB->linksCountPerTag(); + $tags = $this->bookmarkService->bookmarksCountPerTag(); $this->assertEquals(2, $tags[$tagName]); throw $e; }