diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/feed/FeedBuilderTest.php | 12 | ||||
-rw-r--r-- | tests/legacy/LegacyControllerTest.php | 8 | ||||
-rw-r--r-- | tests/security/SessionManagerTest.php | 13 |
3 files changed, 18 insertions, 15 deletions
diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index 5c2aaedb..fe37d5f2 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php | |||
@@ -87,7 +87,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
87 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); | 87 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); |
88 | 88 | ||
89 | // Test first not pinned link (note link) | 89 | // Test first not pinned link (note link) |
90 | $link = $data['links'][array_keys($data['links'])[2]]; | 90 | $link = $data['links'][array_keys($data['links'])[0]]; |
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/shaare/WDWyig', $link['guid']); | 93 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); |
@@ -128,7 +128,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
128 | $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); | 128 | $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, null); |
129 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); | 129 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); |
130 | $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['last_update']); | 130 | $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['last_update']); |
131 | $link = $data['links'][array_keys($data['links'])[2]]; | 131 | $link = $data['links'][array_keys($data['links'])[0]]; |
132 | $this->assertRegExp('/2015-03-10T11:46:51\+\d{2}:\d{2}/', $link['pub_iso_date']); | 132 | $this->assertRegExp('/2015-03-10T11:46:51\+\d{2}:\d{2}/', $link['pub_iso_date']); |
133 | $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['links'][8]['up_iso_date']); | 133 | $this->assertRegExp('/2016-08-03T09:30:33\+\d{2}:\d{2}/', $data['links'][8]['up_iso_date']); |
134 | } | 134 | } |
@@ -173,7 +173,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
173 | $feedBuilder->setLocale(self::$LOCALE); | 173 | $feedBuilder->setLocale(self::$LOCALE); |
174 | $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, $criteria); | 174 | $data = $feedBuilder->buildData(FeedBuilder::$FEED_ATOM, $criteria); |
175 | $this->assertEquals(3, count($data['links'])); | 175 | $this->assertEquals(3, count($data['links'])); |
176 | $link = $data['links'][array_keys($data['links'])[2]]; | 176 | $link = $data['links'][array_keys($data['links'])[0]]; |
177 | $this->assertEquals(41, $link['id']); | 177 | $this->assertEquals(41, $link['id']); |
178 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); | 178 | $this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']); |
179 | } | 179 | } |
@@ -195,7 +195,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
195 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); | 195 | $this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data['links'])); |
196 | $this->assertTrue($data['usepermalinks']); | 196 | $this->assertTrue($data['usepermalinks']); |
197 | // First link is a permalink | 197 | // First link is a permalink |
198 | $link = $data['links'][array_keys($data['links'])[2]]; | 198 | $link = $data['links'][array_keys($data['links'])[0]]; |
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/shaare/WDWyig', $link['guid']); | 201 | $this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']); |
@@ -203,7 +203,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
203 | $this->assertContains('Direct link', $link['description']); | 203 | $this->assertContains('Direct link', $link['description']); |
204 | $this->assertContains('http://host.tld/shaare/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'])[1]]; |
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/shaare/RttfEw', $link['guid']); | 209 | $this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']); |
@@ -270,7 +270,7 @@ class FeedBuilderTest extends \PHPUnit\Framework\TestCase | |||
270 | ); | 270 | ); |
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'])[0]]; |
274 | $this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/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/shaare/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']); |
diff --git a/tests/legacy/LegacyControllerTest.php b/tests/legacy/LegacyControllerTest.php index 759a5b2a..4e52f3e1 100644 --- a/tests/legacy/LegacyControllerTest.php +++ b/tests/legacy/LegacyControllerTest.php | |||
@@ -66,11 +66,11 @@ class LegacyControllerTest extends TestCase | |||
66 | { | 66 | { |
67 | return [ | 67 | return [ |
68 | ['post', [], '/admin/shaare', true], | 68 | ['post', [], '/admin/shaare', true], |
69 | ['post', [], '/login', false], | 69 | ['post', [], '/login?returnurl=/subfolder/admin/shaare', false], |
70 | ['post', ['title' => 'test'], '/admin/shaare?title=test', true], | 70 | ['post', ['title' => 'test'], '/admin/shaare?title=test', true], |
71 | ['post', ['title' => 'test'], '/login?title=test', false], | 71 | ['post', ['title' => 'test'], '/login?returnurl=/subfolder/admin/shaare?title=test', false], |
72 | ['addlink', [], '/admin/add-shaare', true], | 72 | ['addlink', [], '/admin/add-shaare', true], |
73 | ['addlink', [], '/login', false], | 73 | ['addlink', [], '/login?returnurl=/subfolder/admin/add-shaare', false], |
74 | ['login', [], '/login', true], | 74 | ['login', [], '/login', true], |
75 | ['login', [], '/login', false], | 75 | ['login', [], '/login', false], |
76 | ['logout', [], '/admin/logout', true], | 76 | ['logout', [], '/admin/logout', true], |
@@ -94,6 +94,8 @@ class LegacyControllerTest extends TestCase | |||
94 | ['opensearch', [], '/open-search', true], | 94 | ['opensearch', [], '/open-search', true], |
95 | ['dailyrss', [], '/daily-rss', false], | 95 | ['dailyrss', [], '/daily-rss', false], |
96 | ['dailyrss', [], '/daily-rss', true], | 96 | ['dailyrss', [], '/daily-rss', true], |
97 | ['configure', [], '/login?returnurl=/subfolder/admin/configure', false], | ||
98 | ['configure', [], '/admin/configure', true], | ||
97 | ]; | 99 | ]; |
98 | } | 100 | } |
99 | } | 101 | } |
diff --git a/tests/security/SessionManagerTest.php b/tests/security/SessionManagerTest.php index 60695dcf..11a59f9c 100644 --- a/tests/security/SessionManagerTest.php +++ b/tests/security/SessionManagerTest.php | |||
@@ -207,15 +207,16 @@ class SessionManagerTest extends TestCase | |||
207 | 'expires_on' => time() + 1000, | 207 | 'expires_on' => time() + 1000, |
208 | 'username' => 'johndoe', | 208 | 'username' => 'johndoe', |
209 | 'visibility' => 'public', | 209 | 'visibility' => 'public', |
210 | 'untaggedonly' => false, | 210 | 'untaggedonly' => true, |
211 | ]; | 211 | ]; |
212 | $this->sessionManager->logout(); | 212 | $this->sessionManager->logout(); |
213 | 213 | ||
214 | $this->assertFalse(isset($this->session['ip'])); | 214 | $this->assertArrayNotHasKey('ip', $this->session); |
215 | $this->assertFalse(isset($this->session['expires_on'])); | 215 | $this->assertArrayNotHasKey('expires_on', $this->session); |
216 | $this->assertFalse(isset($this->session['username'])); | 216 | $this->assertArrayNotHasKey('username', $this->session); |
217 | $this->assertFalse(isset($this->session['visibility'])); | 217 | $this->assertArrayNotHasKey('visibility', $this->session); |
218 | $this->assertFalse(isset($this->session['untaggedonly'])); | 218 | $this->assertArrayHasKey('untaggedonly', $this->session); |
219 | $this->assertTrue($this->session['untaggedonly']); | ||
219 | } | 220 | } |
220 | 221 | ||
221 | /** | 222 | /** |