diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-07-28 22:24:41 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-28 22:34:45 +0200 |
commit | f7f08ceec1b218e1525153e8bd3d0199f2fb1c9d (patch) | |
tree | f0c1227355b02ab931732b0b37b626f3ec9274cf /tests | |
parent | 624123177f8673f978c49186b43fd96c6827d8a0 (diff) | |
download | Shaarli-f7f08ceec1b218e1525153e8bd3d0199f2fb1c9d.tar.gz Shaarli-f7f08ceec1b218e1525153e8bd3d0199f2fb1c9d.tar.zst Shaarli-f7f08ceec1b218e1525153e8bd3d0199f2fb1c9d.zip |
Fix basePath in unit tests reference DB
Diffstat (limited to 'tests')
-rw-r--r-- | tests/api/controllers/links/GetLinkIdTest.php | 2 | ||||
-rw-r--r-- | tests/api/controllers/links/GetLinksTest.php | 2 | ||||
-rw-r--r-- | tests/bookmark/BookmarkFileServiceTest.php | 4 | ||||
-rw-r--r-- | tests/feed/FeedBuilderTest.php | 18 | ||||
-rw-r--r-- | tests/netscape/BookmarkExportTest.php | 4 | ||||
-rw-r--r-- | tests/updater/UpdaterTest.php | 14 | ||||
-rw-r--r-- | tests/utils/ReferenceLinkDB.php | 8 |
7 files changed, 25 insertions, 27 deletions
diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php index c26411ac..8bb81dc8 100644 --- a/tests/api/controllers/links/GetLinkIdTest.php +++ b/tests/api/controllers/links/GetLinkIdTest.php | |||
@@ -102,7 +102,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase | |||
102 | $this->assertEquals($id, $data['id']); | 102 | $this->assertEquals($id, $data['id']); |
103 | 103 | ||
104 | // Check link elements | 104 | // Check link elements |
105 | $this->assertEquals('http://domain.tld/?WDWyig', $data['url']); | 105 | $this->assertEquals('http://domain.tld/shaare/WDWyig', $data['url']); |
106 | $this->assertEquals('WDWyig', $data['shorturl']); | 106 | $this->assertEquals('WDWyig', $data['shorturl']); |
107 | $this->assertEquals('Link title: @website', $data['title']); | 107 | $this->assertEquals('Link title: @website', $data['title']); |
108 | $this->assertEquals( | 108 | $this->assertEquals( |
diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php index 4e2d55ac..d02e6fad 100644 --- a/tests/api/controllers/links/GetLinksTest.php +++ b/tests/api/controllers/links/GetLinksTest.php | |||
@@ -109,7 +109,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase | |||
109 | 109 | ||
110 | // Check first element fields | 110 | // Check first element fields |
111 | $first = $data[2]; | 111 | $first = $data[2]; |
112 | $this->assertEquals('http://domain.tld/?WDWyig', $first['url']); | 112 | $this->assertEquals('http://domain.tld/shaare/WDWyig', $first['url']); |
113 | $this->assertEquals('WDWyig', $first['shorturl']); | 113 | $this->assertEquals('WDWyig', $first['shorturl']); |
114 | $this->assertEquals('Link title: @website', $first['title']); | 114 | $this->assertEquals('Link title: @website', $first['title']); |
115 | $this->assertEquals( | 115 | $this->assertEquals( |
diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index a8bf47cb..7b1906d3 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php | |||
@@ -340,7 +340,7 @@ class BookmarkFileServiceTest extends TestCase | |||
340 | 340 | ||
341 | $bookmark = $this->privateLinkDB->get(42); | 341 | $bookmark = $this->privateLinkDB->get(42); |
342 | $this->assertEquals(42, $bookmark->getId()); | 342 | $this->assertEquals(42, $bookmark->getId()); |
343 | $this->assertEquals('?WDWyig', $bookmark->getUrl()); | 343 | $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl()); |
344 | $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl()); | 344 | $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl()); |
345 | $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle()); | 345 | $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle()); |
346 | $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription()); | 346 | $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription()); |
@@ -359,7 +359,7 @@ class BookmarkFileServiceTest extends TestCase | |||
359 | 359 | ||
360 | $bookmark = $this->privateLinkDB->get(42); | 360 | $bookmark = $this->privateLinkDB->get(42); |
361 | $this->assertEquals(42, $bookmark->getId()); | 361 | $this->assertEquals(42, $bookmark->getId()); |
362 | $this->assertEquals('?WDWyig', $bookmark->getUrl()); | 362 | $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl()); |
363 | $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl()); | 363 | $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl()); |
364 | $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle()); | 364 | $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle()); |
365 | $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription()); | 365 | $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription()); |
diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index b2b70b70..5c2aaedb 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php | |||
@@ -90,15 +90,15 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
90 | $link = $data['links'][array_keys($data['links'])[2]]; | 90 | $link = $data['links'][array_keys($data['links'])[2]]; |
91 | $this->assertEquals(41, $link['id']); | 91 | $this->assertEquals(41, $link['id']); |
92 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); | 92 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); |
93 | $this->assertEquals('http://host.tld/?WDWyig', $link['guid']); | 93 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); |
94 | $this->assertEquals('http://host.tld/?WDWyig', $link['url']); | 94 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']); |
95 | $this->assertRegExp('/Tue, 10 Mar 2015 11:46:51 \+\d{4}/', $link['pub_iso_date']); | 95 | $this->assertRegExp('/Tue, 10 Mar 2015 11:46:51 \+\d{4}/', $link['pub_iso_date']); |
96 | $pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']); | 96 | $pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']); |
97 | $up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']); | 97 | $up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']); |
98 | $this->assertEquals($pub, $up); | 98 | $this->assertEquals($pub, $up); |
99 | $this->assertContains('Stallman has a beard', $link['description']); | 99 | $this->assertContains('Stallman has a beard', $link['description']); |
100 | $this->assertContains('Permalink', $link['description']); | 100 | $this->assertContains('Permalink', $link['description']); |
101 | $this->assertContains('http://host.tld/?WDWyig', $link['description']); | 101 | $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']); |
102 | $this->assertEquals(1, count($link['taglist'])); | 102 | $this->assertEquals(1, count($link['taglist'])); |
103 | $this->assertEquals('sTuff', $link['taglist'][0]); | 103 | $this->assertEquals('sTuff', $link['taglist'][0]); |
104 | 104 | ||
@@ -198,15 +198,15 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
198 | $link = $data['links'][array_keys($data['links'])[2]]; | 198 | $link = $data['links'][array_keys($data['links'])[2]]; |
199 | $this->assertEquals(41, $link['id']); | 199 | $this->assertEquals(41, $link['id']); |
200 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); | 200 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); |
201 | $this->assertEquals('http://host.tld/?WDWyig', $link['guid']); | 201 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); |
202 | $this->assertEquals('http://host.tld/?WDWyig', $link['url']); | 202 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']); |
203 | $this->assertContains('Direct link', $link['description']); | 203 | $this->assertContains('Direct link', $link['description']); |
204 | $this->assertContains('http://host.tld/?WDWyig', $link['description']); | 204 | $this->assertContains('http://host.tld/shaare/WDWyig', $link['description']); |
205 | // Second link is a direct link | 205 | // Second link is a direct link |
206 | $link = $data['links'][array_keys($data['links'])[3]]; | 206 | $link = $data['links'][array_keys($data['links'])[3]]; |
207 | $this->assertEquals(8, $link['id']); | 207 | $this->assertEquals(8, $link['id']); |
208 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']); | 208 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']); |
209 | $this->assertEquals('http://host.tld/?RttfEw', $link['guid']); | 209 | $this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']); |
210 | $this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']); | 210 | $this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']); |
211 | $this->assertContains('Direct link', $link['description']); | 211 | $this->assertContains('Direct link', $link['description']); |
212 | $this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']); | 212 | $this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']); |
@@ -271,8 +271,8 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
271 | 271 | ||
272 | // Test first link (note link) | 272 | // Test first link (note link) |
273 | $link = $data['links'][array_keys($data['links'])[2]]; | 273 | $link = $data['links'][array_keys($data['links'])[2]]; |
274 | $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['guid']); | 274 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']); |
275 | $this->assertEquals('http://host.tld:8080/~user/shaarli/?WDWyig', $link['url']); | 275 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']); |
276 | $this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']); | 276 | $this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']); |
277 | } | 277 | } |
278 | } | 278 | } |
diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php index 344c1dc0..509da51d 100644 --- a/tests/netscape/BookmarkExportTest.php +++ b/tests/netscape/BookmarkExportTest.php | |||
@@ -177,7 +177,7 @@ class BookmarkExportTest extends TestCase | |||
177 | '' | 177 | '' |
178 | ); | 178 | ); |
179 | $this->assertEquals( | 179 | $this->assertEquals( |
180 | '?WDWyig', | 180 | '/shaare/WDWyig', |
181 | $links[2]['url'] | 181 | $links[2]['url'] |
182 | ); | 182 | ); |
183 | } | 183 | } |
@@ -195,7 +195,7 @@ class BookmarkExportTest extends TestCase | |||
195 | $indexUrl | 195 | $indexUrl |
196 | ); | 196 | ); |
197 | $this->assertEquals( | 197 | $this->assertEquals( |
198 | $indexUrl . '?WDWyig', | 198 | $indexUrl . 'shaare/WDWyig', |
199 | $links[2]['url'] | 199 | $links[2]['url'] |
200 | ); | 200 | ); |
201 | } | 201 | } |
diff --git a/tests/updater/UpdaterTest.php b/tests/updater/UpdaterTest.php index c801d451..a7dd70bf 100644 --- a/tests/updater/UpdaterTest.php +++ b/tests/updater/UpdaterTest.php | |||
@@ -2,6 +2,7 @@ | |||
2 | namespace Shaarli\Updater; | 2 | namespace Shaarli\Updater; |
3 | 3 | ||
4 | use Exception; | 4 | use Exception; |
5 | use PHPUnit\Framework\TestCase; | ||
5 | use Shaarli\Bookmark\BookmarkFileService; | 6 | use Shaarli\Bookmark\BookmarkFileService; |
6 | use Shaarli\Bookmark\BookmarkServiceInterface; | 7 | use Shaarli\Bookmark\BookmarkServiceInterface; |
7 | use Shaarli\Config\ConfigManager; | 8 | use Shaarli\Config\ConfigManager; |
@@ -12,7 +13,7 @@ use Shaarli\History; | |||
12 | * Class UpdaterTest. | 13 | * Class UpdaterTest. |
13 | * Runs unit tests against the updater class. | 14 | * Runs unit tests against the updater class. |
14 | */ | 15 | */ |
15 | class UpdaterTest extends \PHPUnit\Framework\TestCase | 16 | class UpdaterTest extends TestCase |
16 | { | 17 | { |
17 | /** | 18 | /** |
18 | * @var string Path to test datastore. | 19 | * @var string Path to test datastore. |
@@ -194,7 +195,6 @@ class UpdaterTest extends \PHPUnit\Framework\TestCase | |||
194 | 195 | ||
195 | public function testUpdateMethodRelativeHomeLinkDoNotRename(): void | 196 | public function testUpdateMethodRelativeHomeLinkDoNotRename(): void |
196 | { | 197 | { |
197 | $this->updater->setBasePath('/subfolder'); | ||
198 | $this->conf->set('general.header_link', '~/my-blog'); | 198 | $this->conf->set('general.header_link', '~/my-blog'); |
199 | 199 | ||
200 | $this->updater->updateMethodRelativeHomeLink(); | 200 | $this->updater->updateMethodRelativeHomeLink(); |
@@ -204,8 +204,6 @@ class UpdaterTest extends \PHPUnit\Framework\TestCase | |||
204 | 204 | ||
205 | public function testUpdateMethodMigrateExistingNotesUrl(): void | 205 | public function testUpdateMethodMigrateExistingNotesUrl(): void |
206 | { | 206 | { |
207 | $this->updater->setBasePath('/subfolder'); | ||
208 | |||
209 | $this->updater->updateMethodMigrateExistingNotesUrl(); | 207 | $this->updater->updateMethodMigrateExistingNotesUrl(); |
210 | 208 | ||
211 | static::assertSame($this->refDB->getLinks()[0]->getUrl(), $this->bookmarkService->get(0)->getUrl()); | 209 | static::assertSame($this->refDB->getLinks()[0]->getUrl(), $this->bookmarkService->get(0)->getUrl()); |
@@ -215,9 +213,9 @@ class UpdaterTest extends \PHPUnit\Framework\TestCase | |||
215 | static::assertSame($this->refDB->getLinks()[7]->getUrl(), $this->bookmarkService->get(7)->getUrl()); | 213 | 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()); | 214 | 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()); | 215 | static::assertSame($this->refDB->getLinks()[9]->getUrl(), $this->bookmarkService->get(9)->getUrl()); |
218 | static::assertSame('/subfolder/shaare/WDWyig', $this->bookmarkService->get(42)->getUrl()); | 216 | static::assertSame('/shaare/WDWyig', $this->bookmarkService->get(42)->getUrl()); |
219 | static::assertSame('/subfolder/shaare/WDWyig', $this->bookmarkService->get(41)->getUrl()); | 217 | static::assertSame('/shaare/WDWyig', $this->bookmarkService->get(41)->getUrl()); |
220 | static::assertSame('/subfolder/shaare/0gCTjQ', $this->bookmarkService->get(10)->getUrl()); | 218 | static::assertSame('/shaare/0gCTjQ', $this->bookmarkService->get(10)->getUrl()); |
221 | static::assertSame('/subfolder/shaare/PCRizQ', $this->bookmarkService->get(11)->getUrl()); | 219 | static::assertSame('/shaare/PCRizQ', $this->bookmarkService->get(11)->getUrl()); |
222 | } | 220 | } |
223 | } | 221 | } |
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php index 0095f5a1..fc3cb109 100644 --- a/tests/utils/ReferenceLinkDB.php +++ b/tests/utils/ReferenceLinkDB.php | |||
@@ -30,7 +30,7 @@ class ReferenceLinkDB | |||
30 | $this->addLink( | 30 | $this->addLink( |
31 | 11, | 31 | 11, |
32 | 'Pined older', | 32 | 'Pined older', |
33 | '?PCRizQ', | 33 | '/shaare/PCRizQ', |
34 | 'This is an older pinned link', | 34 | 'This is an older pinned link', |
35 | 0, | 35 | 0, |
36 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20100309_101010'), | 36 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20100309_101010'), |
@@ -43,7 +43,7 @@ class ReferenceLinkDB | |||
43 | $this->addLink( | 43 | $this->addLink( |
44 | 10, | 44 | 10, |
45 | 'Pined', | 45 | 'Pined', |
46 | '?0gCTjQ', | 46 | '/shaare/0gCTjQ', |
47 | 'This is a pinned link', | 47 | 'This is a pinned link', |
48 | 0, | 48 | 0, |
49 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20121207_152312'), | 49 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20121207_152312'), |
@@ -56,7 +56,7 @@ class ReferenceLinkDB | |||
56 | $this->addLink( | 56 | $this->addLink( |
57 | 41, | 57 | 41, |
58 | 'Link title: @website', | 58 | 'Link title: @website', |
59 | '?WDWyig', | 59 | '/shaare/WDWyig', |
60 | 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag', | 60 | 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this. #hashtag', |
61 | 0, | 61 | 0, |
62 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), | 62 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), |
@@ -68,7 +68,7 @@ class ReferenceLinkDB | |||
68 | $this->addLink( | 68 | $this->addLink( |
69 | 42, | 69 | 42, |
70 | 'Note: I have a big ID but an old date', | 70 | 'Note: I have a big ID but an old date', |
71 | '?WDWyig', | 71 | '/shaare/WDWyig', |
72 | 'Used to test bookmarks reordering.', | 72 | 'Used to test bookmarks reordering.', |
73 | 0, | 73 | 0, |
74 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20100310_101010'), | 74 | DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20100310_101010'), |