diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/LinkFilterTest.php | 16 | ||||
-rw-r--r-- | tests/LinkUtilsTest.php | 23 | ||||
-rw-r--r-- | tests/Updater/UpdaterTest.php | 20 | ||||
-rw-r--r-- | tests/api/controllers/links/PostLinkTest.php | 8 | ||||
-rw-r--r-- | tests/api/controllers/links/PutLinkTest.php | 8 |
5 files changed, 56 insertions, 19 deletions
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php index 250046f8..eb54c359 100644 --- a/tests/LinkFilterTest.php +++ b/tests/LinkFilterTest.php | |||
@@ -76,7 +76,15 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
76 | 76 | ||
77 | $this->assertEquals( | 77 | $this->assertEquals( |
78 | self::$refDB->countUntaggedLinks(), | 78 | self::$refDB->countUntaggedLinks(), |
79 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, /*$request=*/'', /*$casesensitive=*/false, /*$visibility=*/'all', /*$untaggedonly=*/true)) | 79 | count( |
80 | self::$linkFilter->filter( | ||
81 | LinkFilter::$FILTER_TAG, | ||
82 | /*$request=*/'', | ||
83 | /*$casesensitive=*/false, | ||
84 | /*$visibility=*/'all', | ||
85 | /*$untaggedonly=*/true | ||
86 | ) | ||
87 | ) | ||
80 | ); | 88 | ); |
81 | 89 | ||
82 | $this->assertEquals( | 90 | $this->assertEquals( |
@@ -246,7 +254,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
246 | 2, | 254 | 2, |
247 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'ars.userfriendly.org')) | 255 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'ars.userfriendly.org')) |
248 | ); | 256 | ); |
249 | 257 | ||
250 | $this->assertEquals( | 258 | $this->assertEquals( |
251 | 2, | 259 | 2, |
252 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'ars org')) | 260 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'ars org')) |
@@ -288,12 +296,12 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
288 | 1, | 296 | 1, |
289 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'publishing media')) | 297 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'publishing media')) |
290 | ); | 298 | ); |
291 | 299 | ||
292 | $this->assertEquals( | 300 | $this->assertEquals( |
293 | 1, | 301 | 1, |
294 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'mercurial w3c')) | 302 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'mercurial w3c')) |
295 | ); | 303 | ); |
296 | 304 | ||
297 | $this->assertEquals( | 305 | $this->assertEquals( |
298 | 3, | 306 | 3, |
299 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"')) | 307 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"')) |
diff --git a/tests/LinkUtilsTest.php b/tests/LinkUtilsTest.php index ca062f05..5407159a 100644 --- a/tests/LinkUtilsTest.php +++ b/tests/LinkUtilsTest.php | |||
@@ -83,7 +83,9 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase | |||
83 | 'Date: Sat, 28 Oct 2017 12:01:33 GMT', | 83 | 'Date: Sat, 28 Oct 2017 12:01:33 GMT', |
84 | 'Content-Type: text/html; charset=utf-8', | 84 | 'Content-Type: text/html; charset=utf-8', |
85 | 'Status: 200 OK', | 85 | 'Status: 200 OK', |
86 | 'end' => 'th=device-width"><title>Refactoring · GitHub</title><link rel="search" type="application/opensea', | 86 | 'end' => 'th=device-width">' |
87 | .'<title>Refactoring · GitHub</title>' | ||
88 | .'<link rel="search" type="application/opensea', | ||
87 | '<title>ignored</title>', | 89 | '<title>ignored</title>', |
88 | ]; | 90 | ]; |
89 | foreach ($data as $key => $line) { | 91 | foreach ($data as $key => $line) { |
@@ -106,7 +108,9 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase | |||
106 | $callback = get_curl_download_callback($charset, $title, 'ut_curl_getinfo_no_charset'); | 108 | $callback = get_curl_download_callback($charset, $title, 'ut_curl_getinfo_no_charset'); |
107 | $data = [ | 109 | $data = [ |
108 | 'HTTP/1.1 200 OK', | 110 | 'HTTP/1.1 200 OK', |
109 | 'end' => 'th=device-width"><title>Refactoring · GitHub</title><link rel="search" type="application/opensea', | 111 | 'end' => 'th=device-width">' |
112 | .'<title>Refactoring · GitHub</title>' | ||
113 | .'<link rel="search" type="application/opensea', | ||
110 | '<title>ignored</title>', | 114 | '<title>ignored</title>', |
111 | ]; | 115 | ]; |
112 | foreach ($data as $key => $line) { | 116 | foreach ($data as $key => $line) { |
@@ -126,7 +130,9 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase | |||
126 | $data = [ | 130 | $data = [ |
127 | 'HTTP/1.1 200 OK', | 131 | 'HTTP/1.1 200 OK', |
128 | '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />', | 132 | '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />', |
129 | 'end' => 'th=device-width"><title>Refactoring · GitHub</title><link rel="search" type="application/opensea', | 133 | 'end' => 'th=device-width">' |
134 | .'<title>Refactoring · GitHub</title>' | ||
135 | .'<link rel="search" type="application/opensea', | ||
130 | '<title>ignored</title>', | 136 | '<title>ignored</title>', |
131 | ]; | 137 | ]; |
132 | foreach ($data as $key => $line) { | 138 | foreach ($data as $key => $line) { |
@@ -211,23 +217,26 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase | |||
211 | public function testText2clickableWithoutRedirector() | 217 | public function testText2clickableWithoutRedirector() |
212 | { | 218 | { |
213 | $text = 'stuff http://hello.there/is=someone#here otherstuff'; | 219 | $text = 'stuff http://hello.there/is=someone#here otherstuff'; |
214 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff'; | 220 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here">' |
221 | .'http://hello.there/is=someone#here</a> otherstuff'; | ||
215 | $processedText = text2clickable($text, ''); | 222 | $processedText = text2clickable($text, ''); |
216 | $this->assertEquals($expectedText, $processedText); | 223 | $this->assertEquals($expectedText, $processedText); |
217 | 224 | ||
218 | $text = 'stuff http://hello.there/is=someone#here(please) otherstuff'; | 225 | $text = 'stuff http://hello.there/is=someone#here(please) otherstuff'; |
219 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">http://hello.there/is=someone#here(please)</a> otherstuff'; | 226 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">' |
227 | .'http://hello.there/is=someone#here(please)</a> otherstuff'; | ||
220 | $processedText = text2clickable($text, ''); | 228 | $processedText = text2clickable($text, ''); |
221 | $this->assertEquals($expectedText, $processedText); | 229 | $this->assertEquals($expectedText, $processedText); |
222 | 230 | ||
223 | $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; | 231 | $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; |
224 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">http://hello.there/is=someone#here(please)&no</a> otherstuff'; | 232 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">' |
233 | .'http://hello.there/is=someone#here(please)&no</a> otherstuff'; | ||
225 | $processedText = text2clickable($text, ''); | 234 | $processedText = text2clickable($text, ''); |
226 | $this->assertEquals($expectedText, $processedText); | 235 | $this->assertEquals($expectedText, $processedText); |
227 | } | 236 | } |
228 | 237 | ||
229 | /** | 238 | /** |
230 | * Test text2clickable a redirector set. | 239 | * Test text2clickable with a redirector set. |
231 | */ | 240 | */ |
232 | public function testText2clickableWithRedirector() | 241 | public function testText2clickableWithRedirector() |
233 | { | 242 | { |
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php index 870f169a..c4a6e7ef 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php | |||
@@ -393,20 +393,32 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; | |||
393 | $this->assertEquals('Naming conventions... #private', $linkDB[0]['description']); | 393 | $this->assertEquals('Naming conventions... #private', $linkDB[0]['description']); |
394 | $this->assertEquals('samba cartoon web', $linkDB[0]['tags']); | 394 | $this->assertEquals('samba cartoon web', $linkDB[0]['tags']); |
395 | $this->assertTrue($linkDB[0]['private']); | 395 | $this->assertTrue($linkDB[0]['private']); |
396 | $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_142300'), $linkDB[0]['created']); | 396 | $this->assertEquals( |
397 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_142300'), | ||
398 | $linkDB[0]['created'] | ||
399 | ); | ||
397 | 400 | ||
398 | $this->assertTrue(isset($linkDB[1])); | 401 | $this->assertTrue(isset($linkDB[1])); |
399 | $this->assertFalse(isset($linkDB[1]['linkdate'])); | 402 | $this->assertFalse(isset($linkDB[1]['linkdate'])); |
400 | $this->assertEquals(1, $linkDB[1]['id']); | 403 | $this->assertEquals(1, $linkDB[1]['id']); |
401 | $this->assertEquals('UserFriendly - Samba', $linkDB[1]['title']); | 404 | $this->assertEquals('UserFriendly - Samba', $linkDB[1]['title']); |
402 | $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_172539'), $linkDB[1]['created']); | 405 | $this->assertEquals( |
406 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_172539'), | ||
407 | $linkDB[1]['created'] | ||
408 | ); | ||
403 | 409 | ||
404 | $this->assertTrue(isset($linkDB[2])); | 410 | $this->assertTrue(isset($linkDB[2])); |
405 | $this->assertFalse(isset($linkDB[2]['linkdate'])); | 411 | $this->assertFalse(isset($linkDB[2]['linkdate'])); |
406 | $this->assertEquals(2, $linkDB[2]['id']); | 412 | $this->assertEquals(2, $linkDB[2]['id']); |
407 | $this->assertEquals('Geek and Poke', $linkDB[2]['title']); | 413 | $this->assertEquals('Geek and Poke', $linkDB[2]['title']); |
408 | $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_182539'), $linkDB[2]['created']); | 414 | $this->assertEquals( |
409 | $this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_190301'), $linkDB[2]['updated']); | 415 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_182539'), |
416 | $linkDB[2]['created'] | ||
417 | ); | ||
418 | $this->assertEquals( | ||
419 | DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_190301'), | ||
420 | $linkDB[2]['updated'] | ||
421 | ); | ||
410 | } | 422 | } |
411 | 423 | ||
412 | /** | 424 | /** |
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php index 37617611..5c2b5623 100644 --- a/tests/api/controllers/links/PostLinkTest.php +++ b/tests/api/controllers/links/PostLinkTest.php | |||
@@ -127,7 +127,9 @@ class PostLinkTest extends TestCase | |||
127 | $this->assertEquals('', $data['description']); | 127 | $this->assertEquals('', $data['description']); |
128 | $this->assertEquals([], $data['tags']); | 128 | $this->assertEquals([], $data['tags']); |
129 | $this->assertEquals(false, $data['private']); | 129 | $this->assertEquals(false, $data['private']); |
130 | $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])); | 130 | $this->assertTrue( |
131 | new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | ||
132 | ); | ||
131 | $this->assertEquals('', $data['updated']); | 133 | $this->assertEquals('', $data['updated']); |
132 | 134 | ||
133 | $historyEntry = $this->history->getHistory()[0]; | 135 | $historyEntry = $this->history->getHistory()[0]; |
@@ -170,7 +172,9 @@ class PostLinkTest extends TestCase | |||
170 | $this->assertEquals($link['description'], $data['description']); | 172 | $this->assertEquals($link['description'], $data['description']); |
171 | $this->assertEquals($link['tags'], $data['tags']); | 173 | $this->assertEquals($link['tags'], $data['tags']); |
172 | $this->assertEquals(true, $data['private']); | 174 | $this->assertEquals(true, $data['private']); |
173 | $this->assertTrue(new \DateTime('2 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])); | 175 | $this->assertTrue( |
176 | new \DateTime('2 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | ||
177 | ); | ||
174 | $this->assertEquals('', $data['updated']); | 178 | $this->assertEquals('', $data['updated']); |
175 | } | 179 | } |
176 | 180 | ||
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php index 72b895f2..f276b4c1 100644 --- a/tests/api/controllers/links/PutLinkTest.php +++ b/tests/api/controllers/links/PutLinkTest.php | |||
@@ -114,7 +114,9 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
114 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), | 114 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), |
115 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | 115 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) |
116 | ); | 116 | ); |
117 | $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])); | 117 | $this->assertTrue( |
118 | new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) | ||
119 | ); | ||
118 | 120 | ||
119 | $historyEntry = $this->history->getHistory()[0]; | 121 | $historyEntry = $this->history->getHistory()[0]; |
120 | $this->assertEquals(\History::UPDATED, $historyEntry['event']); | 122 | $this->assertEquals(\History::UPDATED, $historyEntry['event']); |
@@ -159,7 +161,9 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase | |||
159 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), | 161 | \DateTime::createFromFormat('Ymd_His', '20150310_114651'), |
160 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) | 162 | \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) |
161 | ); | 163 | ); |
162 | $this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])); | 164 | $this->assertTrue( |
165 | new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) | ||
166 | ); | ||
163 | } | 167 | } |
164 | 168 | ||
165 | /** | 169 | /** |