diff options
Diffstat (limited to 'tests/updater')
-rw-r--r-- | tests/updater/UpdaterTest.php | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/updater/UpdaterTest.php b/tests/updater/UpdaterTest.php index afc35aec..c801d451 100644 --- a/tests/updater/UpdaterTest.php +++ b/tests/updater/UpdaterTest.php | |||
@@ -7,9 +7,6 @@ use Shaarli\Bookmark\BookmarkServiceInterface; | |||
7 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
8 | use Shaarli\History; | 8 | use Shaarli\History; |
9 | 9 | ||
10 | require_once 'tests/updater/DummyUpdater.php'; | ||
11 | require_once 'tests/utils/ReferenceLinkDB.php'; | ||
12 | require_once 'inc/rain.tpl.class.php'; | ||
13 | 10 | ||
14 | /** | 11 | /** |
15 | * Class UpdaterTest. | 12 | * Class UpdaterTest. |
@@ -35,6 +32,9 @@ class UpdaterTest extends \PHPUnit\Framework\TestCase | |||
35 | /** @var BookmarkServiceInterface */ | 32 | /** @var BookmarkServiceInterface */ |
36 | protected $bookmarkService; | 33 | protected $bookmarkService; |
37 | 34 | ||
35 | /** @var \ReferenceLinkDB */ | ||
36 | protected $refDB; | ||
37 | |||
38 | /** @var Updater */ | 38 | /** @var Updater */ |
39 | protected $updater; | 39 | protected $updater; |
40 | 40 | ||
@@ -43,6 +43,9 @@ class UpdaterTest extends \PHPUnit\Framework\TestCase | |||
43 | */ | 43 | */ |
44 | public function setUp() | 44 | public function setUp() |
45 | { | 45 | { |
46 | $this->refDB = new \ReferenceLinkDB(); | ||
47 | $this->refDB->write(self::$testDatastore); | ||
48 | |||
46 | copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); | 49 | copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); |
47 | $this->conf = new ConfigManager(self::$configFile); | 50 | $this->conf = new ConfigManager(self::$configFile); |
48 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->createMock(History::class), true); | 51 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->createMock(History::class), true); |
@@ -181,9 +184,40 @@ class UpdaterTest extends \PHPUnit\Framework\TestCase | |||
181 | 184 | ||
182 | public function testUpdateMethodRelativeHomeLinkRename(): void | 185 | public function testUpdateMethodRelativeHomeLinkRename(): void |
183 | { | 186 | { |
187 | $this->updater->setBasePath('/subfolder'); | ||
184 | $this->conf->set('general.header_link', '?'); | 188 | $this->conf->set('general.header_link', '?'); |
189 | |||
190 | $this->updater->updateMethodRelativeHomeLink(); | ||
191 | |||
192 | static::assertSame('/subfolder/', $this->conf->get('general.header_link')); | ||
193 | } | ||
194 | |||
195 | public function testUpdateMethodRelativeHomeLinkDoNotRename(): void | ||
196 | { | ||
197 | $this->updater->setBasePath('/subfolder'); | ||
198 | $this->conf->set('general.header_link', '~/my-blog'); | ||
199 | |||
185 | $this->updater->updateMethodRelativeHomeLink(); | 200 | $this->updater->updateMethodRelativeHomeLink(); |
186 | 201 | ||
187 | static::assertSame(); | 202 | static::assertSame('~/my-blog', $this->conf->get('general.header_link')); |
203 | } | ||
204 | |||
205 | public function testUpdateMethodMigrateExistingNotesUrl(): void | ||
206 | { | ||
207 | $this->updater->setBasePath('/subfolder'); | ||
208 | |||
209 | $this->updater->updateMethodMigrateExistingNotesUrl(); | ||
210 | |||
211 | static::assertSame($this->refDB->getLinks()[0]->getUrl(), $this->bookmarkService->get(0)->getUrl()); | ||
212 | static::assertSame($this->refDB->getLinks()[1]->getUrl(), $this->bookmarkService->get(1)->getUrl()); | ||
213 | static::assertSame($this->refDB->getLinks()[4]->getUrl(), $this->bookmarkService->get(4)->getUrl()); | ||
214 | static::assertSame($this->refDB->getLinks()[6]->getUrl(), $this->bookmarkService->get(6)->getUrl()); | ||
215 | static::assertSame($this->refDB->getLinks()[7]->getUrl(), $this->bookmarkService->get(7)->getUrl()); | ||
216 | static::assertSame($this->refDB->getLinks()[8]->getUrl(), $this->bookmarkService->get(8)->getUrl()); | ||
217 | static::assertSame($this->refDB->getLinks()[9]->getUrl(), $this->bookmarkService->get(9)->getUrl()); | ||
218 | static::assertSame('/subfolder/shaare/WDWyig', $this->bookmarkService->get(42)->getUrl()); | ||
219 | static::assertSame('/subfolder/shaare/WDWyig', $this->bookmarkService->get(41)->getUrl()); | ||
220 | static::assertSame('/subfolder/shaare/0gCTjQ', $this->bookmarkService->get(10)->getUrl()); | ||
221 | static::assertSame('/subfolder/shaare/PCRizQ', $this->bookmarkService->get(11)->getUrl()); | ||
188 | } | 222 | } |
189 | } | 223 | } |