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/info/InfoTest.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/info/InfoTest.php')
-rw-r--r-- | tests/api/controllers/info/InfoTest.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php index e70d371b..b5c938e1 100644 --- a/tests/api/controllers/info/InfoTest.php +++ b/tests/api/controllers/info/InfoTest.php | |||
@@ -1,7 +1,10 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli\Api\Controllers; | 2 | namespace Shaarli\Api\Controllers; |
3 | 3 | ||
4 | use PHPUnit\Framework\TestCase; | ||
5 | use Shaarli\Bookmark\BookmarkFileService; | ||
4 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\History; | ||
5 | use Slim\Container; | 8 | use Slim\Container; |
6 | use Slim\Http\Environment; | 9 | use Slim\Http\Environment; |
7 | use Slim\Http\Request; | 10 | use Slim\Http\Request; |
@@ -14,7 +17,7 @@ use Slim\Http\Response; | |||
14 | * | 17 | * |
15 | * @package Api\Controllers | 18 | * @package Api\Controllers |
16 | */ | 19 | */ |
17 | class InfoTest extends \PHPUnit\Framework\TestCase | 20 | class InfoTest extends TestCase |
18 | { | 21 | { |
19 | /** | 22 | /** |
20 | * @var string datastore to test write operations | 23 | * @var string datastore to test write operations |
@@ -42,17 +45,20 @@ class InfoTest extends \PHPUnit\Framework\TestCase | |||
42 | protected $controller; | 45 | protected $controller; |
43 | 46 | ||
44 | /** | 47 | /** |
45 | * Before every test, instantiate a new Api with its config, plugins and links. | 48 | * Before every test, instantiate a new Api with its config, plugins and bookmarks. |
46 | */ | 49 | */ |
47 | public function setUp() | 50 | public function setUp() |
48 | { | 51 | { |
49 | $this->conf = new ConfigManager('tests/utils/config/configJson.json.php'); | 52 | $this->conf = new ConfigManager('tests/utils/config/configJson'); |
53 | $this->conf->set('resource.datastore', self::$testDatastore); | ||
50 | $this->refDB = new \ReferenceLinkDB(); | 54 | $this->refDB = new \ReferenceLinkDB(); |
51 | $this->refDB->write(self::$testDatastore); | 55 | $this->refDB->write(self::$testDatastore); |
52 | 56 | ||
57 | $history = new History('sandbox/history.php'); | ||
58 | |||
53 | $this->container = new Container(); | 59 | $this->container = new Container(); |
54 | $this->container['conf'] = $this->conf; | 60 | $this->container['conf'] = $this->conf; |
55 | $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); | 61 | $this->container['db'] = new BookmarkFileService($this->conf, $history, true); |
56 | $this->container['history'] = null; | 62 | $this->container['history'] = null; |
57 | 63 | ||
58 | $this->controller = new Info($this->container); | 64 | $this->controller = new Info($this->container); |
@@ -84,11 +90,11 @@ class InfoTest extends \PHPUnit\Framework\TestCase | |||
84 | $this->assertEquals(2, $data['private_counter']); | 90 | $this->assertEquals(2, $data['private_counter']); |
85 | $this->assertEquals('Shaarli', $data['settings']['title']); | 91 | $this->assertEquals('Shaarli', $data['settings']['title']); |
86 | $this->assertEquals('?', $data['settings']['header_link']); | 92 | $this->assertEquals('?', $data['settings']['header_link']); |
87 | $this->assertEquals('UTC', $data['settings']['timezone']); | 93 | $this->assertEquals('Europe/Paris', $data['settings']['timezone']); |
88 | $this->assertEquals(ConfigManager::$DEFAULT_PLUGINS, $data['settings']['enabled_plugins']); | 94 | $this->assertEquals(ConfigManager::$DEFAULT_PLUGINS, $data['settings']['enabled_plugins']); |
89 | $this->assertEquals(false, $data['settings']['default_private_links']); | 95 | $this->assertEquals(true, $data['settings']['default_private_links']); |
90 | 96 | ||
91 | $title = 'My links'; | 97 | $title = 'My bookmarks'; |
92 | $headerLink = 'http://shaarli.tld'; | 98 | $headerLink = 'http://shaarli.tld'; |
93 | $timezone = 'Europe/Paris'; | 99 | $timezone = 'Europe/Paris'; |
94 | $enabledPlugins = array('foo', 'bar'); | 100 | $enabledPlugins = array('foo', 'bar'); |