aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ApplicationUtilsTest.php6
-rw-r--r--tests/CacheTest.php2
-rw-r--r--tests/HttpUtils/GetIpAdressFromProxyTest.php3
-rw-r--r--tests/LinkDBTest.php6
-rw-r--r--tests/LinkFilterTest.php18
-rw-r--r--tests/LinkUtilsTest.php24
-rw-r--r--tests/RouterTest.php1
-rw-r--r--tests/ThumbnailerTest.php8
-rw-r--r--tests/Updater/DummyUpdater.php8
-rw-r--r--tests/Updater/UpdaterTest.php20
-rw-r--r--tests/Url/CleanupUrlTest.php1
-rw-r--r--tests/Url/GetUrlSchemeTest.php1
-rw-r--r--tests/Url/UnparseUrlTest.php1
-rw-r--r--tests/Url/UrlTest.php6
-rw-r--r--tests/UtilsTest.php9
-rw-r--r--tests/api/ApiUtilsTest.php3
-rw-r--r--tests/api/controllers/history/HistoryTest.php1
-rw-r--r--tests/api/controllers/info/InfoTest.php4
-rw-r--r--tests/api/controllers/links/PostLinkTest.php9
-rw-r--r--tests/api/controllers/links/PutLinkTest.php9
-rw-r--r--tests/api/controllers/tags/PutTagTest.php1
-rw-r--r--tests/languages/de/UtilsDeTest.php2
-rw-r--r--tests/languages/fr/LanguagesFrTest.php1
-rw-r--r--tests/plugins/PluginQrcodeTest.php3
-rw-r--r--tests/security/SessionManagerTest.php1
-rw-r--r--tests/utils/ReferenceLinkDB.php6
-rw-r--r--tests/utils/config/configPhp.php2
27 files changed, 94 insertions, 62 deletions
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php
index ff4c9e17..fe5f84ce 100644
--- a/tests/ApplicationUtilsTest.php
+++ b/tests/ApplicationUtilsTest.php
@@ -17,7 +17,7 @@ class FakeApplicationUtils extends ApplicationUtils
17 /** 17 /**
18 * Toggle HTTP requests, allow overriding the version code 18 * Toggle HTTP requests, allow overriding the version code
19 */ 19 */
20 public static function getVersion($url, $timeout=0) 20 public static function getVersion($url, $timeout = 0)
21 { 21 {
22 return self::$VERSION_CODE; 22 return self::$VERSION_CODE;
23 } 23 }
@@ -67,7 +67,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
67 '0.5.4', 67 '0.5.4',
68 ApplicationUtils::getVersion( 68 ApplicationUtils::getVersion(
69 'https://raw.githubusercontent.com/shaarli/Shaarli/' 69 'https://raw.githubusercontent.com/shaarli/Shaarli/'
70 .'v0.5.4/shaarli_version.php', 70 .'v0.5.4/shaarli_version.php',
71 $testTimeout 71 $testTimeout
72 ) 72 )
73 ); 73 );
@@ -75,7 +75,7 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
75 self::$versionPattern, 75 self::$versionPattern,
76 ApplicationUtils::getVersion( 76 ApplicationUtils::getVersion(
77 'https://raw.githubusercontent.com/shaarli/Shaarli/' 77 'https://raw.githubusercontent.com/shaarli/Shaarli/'
78 .'latest/shaarli_version.php', 78 .'latest/shaarli_version.php',
79 $testTimeout 79 $testTimeout
80 ) 80 )
81 ); 81 );
diff --git a/tests/CacheTest.php b/tests/CacheTest.php
index 992e26a5..f60fad91 100644
--- a/tests/CacheTest.php
+++ b/tests/CacheTest.php
@@ -84,7 +84,7 @@ class CacheTest extends PHPUnit_Framework_TestCase
84 invalidateCaches(self::$testCacheDir); 84 invalidateCaches(self::$testCacheDir);
85 foreach (self::$pages as $page) { 85 foreach (self::$pages as $page) {
86 $this->assertFileNotExists(self::$testCacheDir.'/'.$page.'.cache'); 86 $this->assertFileNotExists(self::$testCacheDir.'/'.$page.'.cache');
87 } 87 }
88 88
89 $this->assertArrayNotHasKey('tags', $_SESSION); 89 $this->assertArrayNotHasKey('tags', $_SESSION);
90 } 90 }
diff --git a/tests/HttpUtils/GetIpAdressFromProxyTest.php b/tests/HttpUtils/GetIpAdressFromProxyTest.php
index 6a74a45a..7af5bd9d 100644
--- a/tests/HttpUtils/GetIpAdressFromProxyTest.php
+++ b/tests/HttpUtils/GetIpAdressFromProxyTest.php
@@ -5,7 +5,8 @@ require_once 'application/HttpUtils.php';
5/** 5/**
6 * Unitary tests for getIpAddressFromProxy() 6 * Unitary tests for getIpAddressFromProxy()
7 */ 7 */
8class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase { 8class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase
9{
9 10
10 /** 11 /**
11 * Test without proxy 12 * Test without proxy
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index fcab76f6..c763c0cb 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -362,7 +362,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
362 public function testLinkRealUrlWithoutRedirector() 362 public function testLinkRealUrlWithoutRedirector()
363 { 363 {
364 $db = new LinkDB(self::$testDatastore, false, false); 364 $db = new LinkDB(self::$testDatastore, false, false);
365 foreach($db as $link) { 365 foreach ($db as $link) {
366 $this->assertEquals($link['url'], $link['real_url']); 366 $this->assertEquals($link['url'], $link['real_url']);
367 } 367 }
368 } 368 }
@@ -374,13 +374,13 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
374 { 374 {
375 $redirector = 'http://redirector.to?'; 375 $redirector = 'http://redirector.to?';
376 $db = new LinkDB(self::$testDatastore, false, false, $redirector); 376 $db = new LinkDB(self::$testDatastore, false, false, $redirector);
377 foreach($db as $link) { 377 foreach ($db as $link) {
378 $this->assertStringStartsWith($redirector, $link['real_url']); 378 $this->assertStringStartsWith($redirector, $link['real_url']);
379 $this->assertNotFalse(strpos($link['real_url'], urlencode('://'))); 379 $this->assertNotFalse(strpos($link['real_url'], urlencode('://')));
380 } 380 }
381 381
382 $db = new LinkDB(self::$testDatastore, false, false, $redirector, false); 382 $db = new LinkDB(self::$testDatastore, false, false, $redirector, false);
383 foreach($db as $link) { 383 foreach ($db as $link) {
384 $this->assertStringStartsWith($redirector, $link['real_url']); 384 $this->assertStringStartsWith($redirector, $link['real_url']);
385 $this->assertFalse(strpos($link['real_url'], urlencode('://'))); 385 $this->assertFalse(strpos($link['real_url'], urlencode('://')));
386 } 386 }
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php
index 9cd6dbd4..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,16 +296,16 @@ 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"'))
300 ); 308 );
301 } 309 }
302 310
303 /** 311 /**
diff --git a/tests/LinkUtilsTest.php b/tests/LinkUtilsTest.php
index 7fbd59b0..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 {
@@ -410,4 +419,3 @@ function ut_curl_getinfo_rs_ct_ko($ch, $type)
410 return 'text/plain'; 419 return 'text/plain';
411 } 420 }
412} 421}
413
diff --git a/tests/RouterTest.php b/tests/RouterTest.php
index 544bcf9c..abf1bd5f 100644
--- a/tests/RouterTest.php
+++ b/tests/RouterTest.php
@@ -218,7 +218,6 @@ class RouterTest extends PHPUnit_Framework_TestCase
218 Router::$PAGE_CHANGEPASSWORD, 218 Router::$PAGE_CHANGEPASSWORD,
219 Router::findPage('do=changepasswd&stuff', array(), true) 219 Router::findPage('do=changepasswd&stuff', array(), true)
220 ); 220 );
221
222 } 221 }
223 222
224 /** 223 /**
diff --git a/tests/ThumbnailerTest.php b/tests/ThumbnailerTest.php
index 08311545..c01849f7 100644
--- a/tests/ThumbnailerTest.php
+++ b/tests/ThumbnailerTest.php
@@ -98,15 +98,17 @@ class ThumbnailerTest extends TestCase
98 ini_set('error_log', $oldlog); 98 ini_set('error_log', $oldlog);
99 } 99 }
100 100
101 protected function rrmdirContent($dir) { 101 protected function rrmdirContent($dir)
102 {
102 if (is_dir($dir)) { 103 if (is_dir($dir)) {
103 $objects = scandir($dir); 104 $objects = scandir($dir);
104 foreach ($objects as $object) { 105 foreach ($objects as $object) {
105 if ($object != "." && $object != "..") { 106 if ($object != "." && $object != "..") {
106 if (is_dir($dir."/".$object)) 107 if (is_dir($dir."/".$object)) {
107 $this->rrmdirContent($dir."/".$object); 108 $this->rrmdirContent($dir."/".$object);
108 else 109 } else {
109 unlink($dir."/".$object); 110 unlink($dir."/".$object);
111 }
110 } 112 }
111 } 113 }
112 } 114 }
diff --git a/tests/Updater/DummyUpdater.php b/tests/Updater/DummyUpdater.php
index a0be4413..a805ab5e 100644
--- a/tests/Updater/DummyUpdater.php
+++ b/tests/Updater/DummyUpdater.php
@@ -31,7 +31,7 @@ class DummyUpdater extends Updater
31 * 31 *
32 * @return bool true. 32 * @return bool true.
33 */ 33 */
34 private final function updateMethodDummy1() 34 final private function updateMethodDummy1()
35 { 35 {
36 return true; 36 return true;
37 } 37 }
@@ -41,7 +41,7 @@ class DummyUpdater extends Updater
41 * 41 *
42 * @return bool true. 42 * @return bool true.
43 */ 43 */
44 private final function updateMethodDummy2() 44 final private function updateMethodDummy2()
45 { 45 {
46 return true; 46 return true;
47 } 47 }
@@ -51,7 +51,7 @@ class DummyUpdater extends Updater
51 * 51 *
52 * @return bool true. 52 * @return bool true.
53 */ 53 */
54 private final function updateMethodDummy3() 54 final private function updateMethodDummy3()
55 { 55 {
56 return true; 56 return true;
57 } 57 }
@@ -61,7 +61,7 @@ class DummyUpdater extends Updater
61 * 61 *
62 * @throws Exception error. 62 * @throws Exception error.
63 */ 63 */
64 private final function updateMethodException() 64 final private function updateMethodException()
65 { 65 {
66 throw new Exception('whatever'); 66 throw new Exception('whatever');
67 } 67 }
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/Url/CleanupUrlTest.php b/tests/Url/CleanupUrlTest.php
index 1407d7d2..24791948 100644
--- a/tests/Url/CleanupUrlTest.php
+++ b/tests/Url/CleanupUrlTest.php
@@ -107,4 +107,3 @@ class CleanupUrlTest extends PHPUnit_Framework_TestCase
107 ); 107 );
108 } 108 }
109} 109}
110
diff --git a/tests/Url/GetUrlSchemeTest.php b/tests/Url/GetUrlSchemeTest.php
index 72d80b30..18b932d6 100644
--- a/tests/Url/GetUrlSchemeTest.php
+++ b/tests/Url/GetUrlSchemeTest.php
@@ -28,4 +28,3 @@ class GetUrlSchemeTest extends PHPUnit_Framework_TestCase
28 $this->assertEquals('git', get_url_scheme('git://domain.tld/push?pull=clone#checkout')); 28 $this->assertEquals('git', get_url_scheme('git://domain.tld/push?pull=clone#checkout'));
29 } 29 }
30} 30}
31
diff --git a/tests/Url/UnparseUrlTest.php b/tests/Url/UnparseUrlTest.php
index edde73e4..e314b484 100644
--- a/tests/Url/UnparseUrlTest.php
+++ b/tests/Url/UnparseUrlTest.php
@@ -28,4 +28,3 @@ class UnparseUrlTest extends PHPUnit_Framework_TestCase
28 $this->assertEquals($ref, unparse_url(parse_url($ref))); 28 $this->assertEquals($ref, unparse_url(parse_url($ref)));
29 } 29 }
30} 30}
31
diff --git a/tests/Url/UrlTest.php b/tests/Url/UrlTest.php
index aa2f2234..db229ce0 100644
--- a/tests/Url/UrlTest.php
+++ b/tests/Url/UrlTest.php
@@ -16,7 +16,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
16 /** 16 /**
17 * Helper method 17 * Helper method
18 */ 18 */
19 private function assertUrlIsCleaned($query='', $fragment='') 19 private function assertUrlIsCleaned($query = '', $fragment = '')
20 { 20 {
21 $url = new Url(self::$baseUrl.$query.$fragment); 21 $url = new Url(self::$baseUrl.$query.$fragment);
22 $url->cleanup(); 22 $url->cleanup();
@@ -135,13 +135,13 @@ class UrlTest extends PHPUnit_Framework_TestCase
135 'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept') 135 'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept')
136 ); 136 );
137 $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup()); 137 $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup());
138
139 } 138 }
140 139
141 /** 140 /**
142 * Test default http scheme. 141 * Test default http scheme.
143 */ 142 */
144 public function testDefaultScheme() { 143 public function testDefaultScheme()
144 {
145 $url = new Url(self::$baseUrl); 145 $url = new Url(self::$baseUrl);
146 $this->assertEquals('http', $url->getScheme()); 146 $this->assertEquals('http', $url->getScheme());
147 $url = new Url('domain.tld'); 147 $url = new Url('domain.tld');
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php
index 6cd37a7a..d0abd996 100644
--- a/tests/UtilsTest.php
+++ b/tests/UtilsTest.php
@@ -187,7 +187,8 @@ class UtilsTest extends PHPUnit_Framework_TestCase
187 /** 187 /**
188 * Test generate location with valid data. 188 * Test generate location with valid data.
189 */ 189 */
190 public function testGenerateLocation() { 190 public function testGenerateLocation()
191 {
191 $ref = 'http://localhost/?test'; 192 $ref = 'http://localhost/?test';
192 $this->assertEquals($ref, generateLocation($ref, 'localhost')); 193 $this->assertEquals($ref, generateLocation($ref, 'localhost'));
193 $ref = 'http://localhost:8080/?test'; 194 $ref = 'http://localhost:8080/?test';
@@ -199,7 +200,8 @@ class UtilsTest extends PHPUnit_Framework_TestCase
199 /** 200 /**
200 * Test generate location - anti loop. 201 * Test generate location - anti loop.
201 */ 202 */
202 public function testGenerateLocationLoop() { 203 public function testGenerateLocationLoop()
204 {
203 $ref = 'http://localhost/?test'; 205 $ref = 'http://localhost/?test';
204 $this->assertEquals('?', generateLocation($ref, 'localhost', array('test'))); 206 $this->assertEquals('?', generateLocation($ref, 'localhost', array('test')));
205 } 207 }
@@ -207,7 +209,8 @@ class UtilsTest extends PHPUnit_Framework_TestCase
207 /** 209 /**
208 * Test generate location - from other domain. 210 * Test generate location - from other domain.
209 */ 211 */
210 public function testGenerateLocationOut() { 212 public function testGenerateLocationOut()
213 {
211 $ref = 'http://somewebsite.com/?test'; 214 $ref = 'http://somewebsite.com/?test';
212 $this->assertEquals('?', generateLocation($ref, 'localhost')); 215 $this->assertEquals('?', generateLocation($ref, 'localhost'));
213 } 216 }
diff --git a/tests/api/ApiUtilsTest.php b/tests/api/ApiUtilsTest.php
index 62baf4c5..df4e189a 100644
--- a/tests/api/ApiUtilsTest.php
+++ b/tests/api/ApiUtilsTest.php
@@ -4,7 +4,6 @@ namespace Shaarli\Api;
4 4
5use Shaarli\Base64Url; 5use Shaarli\Base64Url;
6 6
7
8/** 7/**
9 * Class ApiUtilsTest 8 * Class ApiUtilsTest
10 */ 9 */
@@ -34,7 +33,7 @@ class ApiUtilsTest extends \PHPUnit_Framework_TestCase
34 $payload = Base64Url::encode('{ 33 $payload = Base64Url::encode('{
35 "iat": '. time() .' 34 "iat": '. time() .'
36 }'); 35 }');
37 $signature = Base64Url::encode(hash_hmac('sha512', $header .'.'. $payload , $secret, true)); 36 $signature = Base64Url::encode(hash_hmac('sha512', $header .'.'. $payload, $secret, true));
38 return $header .'.'. $payload .'.'. $signature; 37 return $header .'.'. $payload .'.'. $signature;
39 } 38 }
40 39
diff --git a/tests/api/controllers/history/HistoryTest.php b/tests/api/controllers/history/HistoryTest.php
index 61046d97..ff34e16d 100644
--- a/tests/api/controllers/history/HistoryTest.php
+++ b/tests/api/controllers/history/HistoryTest.php
@@ -3,7 +3,6 @@
3 3
4namespace Shaarli\Api\Controllers; 4namespace Shaarli\Api\Controllers;
5 5
6
7use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
8use Slim\Container; 7use Slim\Container;
9use Slim\Http\Environment; 8use Slim\Http\Environment;
diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php
index f7e63bfa..e437082a 100644
--- a/tests/api/controllers/info/InfoTest.php
+++ b/tests/api/controllers/info/InfoTest.php
@@ -10,9 +10,9 @@ use Slim\Http\Response;
10 10
11/** 11/**
12 * Class InfoTest 12 * Class InfoTest
13 * 13 *
14 * Test REST API controller Info. 14 * Test REST API controller Info.
15 * 15 *
16 * @package Api\Controllers 16 * @package Api\Controllers
17 */ 17 */
18class InfoTest extends \PHPUnit_Framework_TestCase 18class InfoTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php
index 100a9170..5c2b5623 100644
--- a/tests/api/controllers/links/PostLinkTest.php
+++ b/tests/api/controllers/links/PostLinkTest.php
@@ -2,7 +2,6 @@
2 2
3namespace Shaarli\Api\Controllers; 3namespace Shaarli\Api\Controllers;
4 4
5
6use PHPUnit\Framework\TestCase; 5use PHPUnit\Framework\TestCase;
7use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
8use Slim\Container; 7use Slim\Container;
@@ -128,7 +127,9 @@ class PostLinkTest extends TestCase
128 $this->assertEquals('', $data['description']); 127 $this->assertEquals('', $data['description']);
129 $this->assertEquals([], $data['tags']); 128 $this->assertEquals([], $data['tags']);
130 $this->assertEquals(false, $data['private']); 129 $this->assertEquals(false, $data['private']);
131 $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 );
132 $this->assertEquals('', $data['updated']); 133 $this->assertEquals('', $data['updated']);
133 134
134 $historyEntry = $this->history->getHistory()[0]; 135 $historyEntry = $this->history->getHistory()[0];
@@ -171,7 +172,9 @@ class PostLinkTest extends TestCase
171 $this->assertEquals($link['description'], $data['description']); 172 $this->assertEquals($link['description'], $data['description']);
172 $this->assertEquals($link['tags'], $data['tags']); 173 $this->assertEquals($link['tags'], $data['tags']);
173 $this->assertEquals(true, $data['private']); 174 $this->assertEquals(true, $data['private']);
174 $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 );
175 $this->assertEquals('', $data['updated']); 178 $this->assertEquals('', $data['updated']);
176 } 179 }
177 180
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php
index 8a562571..f276b4c1 100644
--- a/tests/api/controllers/links/PutLinkTest.php
+++ b/tests/api/controllers/links/PutLinkTest.php
@@ -3,7 +3,6 @@
3 3
4namespace Shaarli\Api\Controllers; 4namespace Shaarli\Api\Controllers;
5 5
6
7use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
8use Slim\Container; 7use Slim\Container;
9use Slim\Http\Environment; 8use Slim\Http\Environment;
@@ -115,7 +114,9 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
115 \DateTime::createFromFormat('Ymd_His', '20150310_114651'), 114 \DateTime::createFromFormat('Ymd_His', '20150310_114651'),
116 \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) 115 \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
117 ); 116 );
118 $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 );
119 120
120 $historyEntry = $this->history->getHistory()[0]; 121 $historyEntry = $this->history->getHistory()[0];
121 $this->assertEquals(\History::UPDATED, $historyEntry['event']); 122 $this->assertEquals(\History::UPDATED, $historyEntry['event']);
@@ -160,7 +161,9 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
160 \DateTime::createFromFormat('Ymd_His', '20150310_114651'), 161 \DateTime::createFromFormat('Ymd_His', '20150310_114651'),
161 \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) 162 \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
162 ); 163 );
163 $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 );
164 } 167 }
165 168
166 /** 169 /**
diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php
index 6f7dec22..38017243 100644
--- a/tests/api/controllers/tags/PutTagTest.php
+++ b/tests/api/controllers/tags/PutTagTest.php
@@ -3,7 +3,6 @@
3 3
4namespace Shaarli\Api\Controllers; 4namespace Shaarli\Api\Controllers;
5 5
6
7use Shaarli\Api\Exceptions\ApiBadParametersException; 6use Shaarli\Api\Exceptions\ApiBadParametersException;
8use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
9use Slim\Container; 8use Slim\Container;
diff --git a/tests/languages/de/UtilsDeTest.php b/tests/languages/de/UtilsDeTest.php
index 4569c923..588c9fd6 100644
--- a/tests/languages/de/UtilsDeTest.php
+++ b/tests/languages/de/UtilsDeTest.php
@@ -20,7 +20,7 @@ class UtilsDeTest extends UtilsTest
20 public function testDateFormatNoTime() 20 public function testDateFormatNoTime()
21 { 21 {
22 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112'); 22 $date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
23 $this->assertRegExp('/1\. Januar 2017/', format_date($date, false,true)); 23 $this->assertRegExp('/1\. Januar 2017/', format_date($date, false, true));
24 } 24 }
25 25
26 /** 26 /**
diff --git a/tests/languages/fr/LanguagesFrTest.php b/tests/languages/fr/LanguagesFrTest.php
index 0cf74891..38347de1 100644
--- a/tests/languages/fr/LanguagesFrTest.php
+++ b/tests/languages/fr/LanguagesFrTest.php
@@ -3,7 +3,6 @@
3 3
4namespace Shaarli; 4namespace Shaarli;
5 5
6
7use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
8 7
9/** 8/**
diff --git a/tests/plugins/PluginQrcodeTest.php b/tests/plugins/PluginQrcodeTest.php
index ebfadddf..dd632eee 100644
--- a/tests/plugins/PluginQrcodeTest.php
+++ b/tests/plugins/PluginQrcodeTest.php
@@ -15,7 +15,8 @@ class PluginQrcodeTest extends PHPUnit_Framework_TestCase
15 /** 15 /**
16 * Reset plugin path 16 * Reset plugin path
17 */ 17 */
18 public function setUp() { 18 public function setUp()
19 {
19 PluginManager::$PLUGINS_PATH = 'plugins'; 20 PluginManager::$PLUGINS_PATH = 'plugins';
20 } 21 }
21 22
diff --git a/tests/security/SessionManagerTest.php b/tests/security/SessionManagerTest.php
index 9bd868f8..7961e771 100644
--- a/tests/security/SessionManagerTest.php
+++ b/tests/security/SessionManagerTest.php
@@ -8,7 +8,6 @@ ReferenceSessionIdHashes::genAllHashes();
8use \Shaarli\Security\SessionManager; 8use \Shaarli\Security\SessionManager;
9use \PHPUnit\Framework\TestCase; 9use \PHPUnit\Framework\TestCase;
10 10
11
12/** 11/**
13 * Test coverage for SessionManager 12 * Test coverage for SessionManager
14 */ 13 */
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php
index 7426ad07..59679e38 100644
--- a/tests/utils/ReferenceLinkDB.php
+++ b/tests/utils/ReferenceLinkDB.php
@@ -150,8 +150,8 @@ class ReferenceLinkDB
150 $tags, 150 $tags,
151 $updated = '', 151 $updated = '',
152 $shorturl = '', 152 $shorturl = '',
153 $pinned = false) 153 $pinned = false
154 { 154 ) {
155 $link = array( 155 $link = array(
156 'id' => $id, 156 'id' => $id,
157 'title' => $title, 157 'title' => $title,
@@ -201,7 +201,7 @@ class ReferenceLinkDB
201 201
202 $order = $order === 'ASC' ? -1 : 1; 202 $order = $order === 'ASC' ? -1 : 1;
203 // Reorder array by dates. 203 // Reorder array by dates.
204 usort($this->_links, function($a, $b) use ($order) { 204 usort($this->_links, function ($a, $b) use ($order) {
205 if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) { 205 if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) {
206 return $a['sticky'] ? -1 : 1; 206 return $a['sticky'] ? -1 : 1;
207 } 207 }
diff --git a/tests/utils/config/configPhp.php b/tests/utils/config/configPhp.php
index 0e034175..34b11fcd 100644
--- a/tests/utils/config/configPhp.php
+++ b/tests/utils/config/configPhp.php
@@ -1,4 +1,4 @@
1<?php 1<?php
2$GLOBALS['login'] = 'root'; 2$GLOBALS['login'] = 'root';
3$GLOBALS['hash'] = 'hash'; 3$GLOBALS['hash'] = 'hash';
4$GLOBALS['salt'] = 'salt'; 4$GLOBALS['salt'] = 'salt';