diff options
-rw-r--r-- | application/HttpUtils.php | 3 | ||||
-rw-r--r-- | application/Languages.php | 4 | ||||
-rw-r--r-- | application/LinkDB.php | 15 | ||||
-rw-r--r-- | application/NetscapeBookmarkUtils.php | 5 | ||||
-rw-r--r-- | application/Thumbnailer.php | 5 | ||||
-rw-r--r-- | application/config/ConfigPhp.php | 12 | ||||
-rw-r--r-- | index.php | 49 | ||||
-rw-r--r-- | plugins/demo_plugin/demo_plugin.php | 8 | ||||
-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 |
13 files changed, 132 insertions, 44 deletions
diff --git a/application/HttpUtils.php b/application/HttpUtils.php index ef6f3264..9c438160 100644 --- a/application/HttpUtils.php +++ b/application/HttpUtils.php | |||
@@ -7,7 +7,8 @@ | |||
7 | * @param int $timeout network timeout (in seconds) | 7 | * @param int $timeout network timeout (in seconds) |
8 | * @param int $maxBytes maximum downloaded bytes (default: 4 MiB) | 8 | * @param int $maxBytes maximum downloaded bytes (default: 4 MiB) |
9 | * @param callable|string $curlWriteFunction Optional callback called during the download (cURL CURLOPT_WRITEFUNCTION). | 9 | * @param callable|string $curlWriteFunction Optional callback called during the download (cURL CURLOPT_WRITEFUNCTION). |
10 | * Can be used to add download conditions on the headers (response code, content type, etc.). | 10 | * Can be used to add download conditions on the |
11 | * headers (response code, content type, etc.). | ||
11 | * | 12 | * |
12 | * @return array HTTP response headers, downloaded content | 13 | * @return array HTTP response headers, downloaded content |
13 | * | 14 | * |
diff --git a/application/Languages.php b/application/Languages.php index 6a6247c7..b9c5d0e8 100644 --- a/application/Languages.php +++ b/application/Languages.php | |||
@@ -149,7 +149,9 @@ class Languages | |||
149 | } | 149 | } |
150 | 150 | ||
151 | try { | 151 | try { |
152 | $extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po'); | 152 | $extension = Translations::fromPoFile( |
153 | $translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po' | ||
154 | ); | ||
153 | $extension->setDomain($domain); | 155 | $extension->setDomain($domain); |
154 | $this->translator->loadTranslations($extension); | 156 | $this->translator->loadTranslations($extension); |
155 | } catch (\InvalidArgumentException $e) { | 157 | } catch (\InvalidArgumentException $e) { |
diff --git a/application/LinkDB.php b/application/LinkDB.php index 1f7c28cd..4bbc2950 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php | |||
@@ -249,11 +249,14 @@ class LinkDB implements Iterator, Countable, ArrayAccess | |||
249 | 'id' => 1, | 249 | 'id' => 1, |
250 | 'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'), | 250 | 'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'), |
251 | 'url'=>'https://shaarli.readthedocs.io', | 251 | 'url'=>'https://shaarli.readthedocs.io', |
252 | 'description'=>t('Welcome to Shaarli! This is your first public bookmark. To edit or delete me, you must first login. | 252 | 'description'=>t( |
253 | 'Welcome to Shaarli! This is your first public bookmark. ' | ||
254 | .'To edit or delete me, you must first login. | ||
253 | 255 | ||
254 | To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page. | 256 | To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page. |
255 | 257 | ||
256 | You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'), | 258 | You use the community supported version of the original Shaarli project, by Sebastien Sauvage.' |
259 | ), | ||
257 | 'private'=>0, | 260 | 'private'=>0, |
258 | 'created'=> new DateTime(), | 261 | 'created'=> new DateTime(), |
259 | 'tags'=>'opensource software' | 262 | 'tags'=>'opensource software' |
@@ -419,8 +422,12 @@ You use the community supported version of the original Shaarli project, by Seba | |||
419 | * | 422 | * |
420 | * @return array filtered links, all links if no suitable filter was provided. | 423 | * @return array filtered links, all links if no suitable filter was provided. |
421 | */ | 424 | */ |
422 | public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all', $untaggedonly = false) | 425 | public function filterSearch( |
423 | { | 426 | $filterRequest = array(), |
427 | $casesensitive = false, | ||
428 | $visibility = 'all', | ||
429 | $untaggedonly = false | ||
430 | ) { | ||
424 | // Filter link database according to parameters. | 431 | // Filter link database according to parameters. |
425 | $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; | 432 | $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; |
426 | $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; | 433 | $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; |
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php index e147d326..84dd2b20 100644 --- a/application/NetscapeBookmarkUtils.php +++ b/application/NetscapeBookmarkUtils.php | |||
@@ -82,7 +82,10 @@ class NetscapeBookmarkUtils | |||
82 | $status .= t('has an unknown file format. Nothing was imported.'); | 82 | $status .= t('has an unknown file format. Nothing was imported.'); |
83 | } else { | 83 | } else { |
84 | $status .= vsprintf( | 84 | $status .= vsprintf( |
85 | t('was successfully processed in %d seconds: %d links imported, %d links overwritten, %d links skipped.'), | 85 | t( |
86 | 'was successfully processed in %d seconds: ' | ||
87 | .'%d links imported, %d links overwritten, %d links skipped.' | ||
88 | ), | ||
86 | [$duration, $importCount, $overwriteCount, $skipCount] | 89 | [$duration, $importCount, $overwriteCount, $skipCount] |
87 | ); | 90 | ); |
88 | } | 91 | } |
diff --git a/application/Thumbnailer.php b/application/Thumbnailer.php index 7d0d9c33..37ed97a1 100644 --- a/application/Thumbnailer.php +++ b/application/Thumbnailer.php | |||
@@ -58,7 +58,10 @@ class Thumbnailer | |||
58 | $this->conf->set('thumbnails.enabled', false); | 58 | $this->conf->set('thumbnails.enabled', false); |
59 | $this->conf->write(true); | 59 | $this->conf->write(true); |
60 | // TODO: create a proper error handling system able to catch exceptions... | 60 | // TODO: create a proper error handling system able to catch exceptions... |
61 | die(t('php-gd extension must be loaded to use thumbnails. Thumbnails are now disabled. Please reload the page.')); | 61 | die(t( |
62 | 'php-gd extension must be loaded to use thumbnails. ' | ||
63 | .'Thumbnails are now disabled. Please reload the page.' | ||
64 | )); | ||
62 | } | 65 | } |
63 | 66 | ||
64 | $this->wt = new WebThumbnailer(); | 67 | $this->wt = new WebThumbnailer(); |
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index 8add8bcd..9625fe1a 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php | |||
@@ -104,12 +104,20 @@ class ConfigPhp implements ConfigIO | |||
104 | 104 | ||
105 | // Store all $conf['config'] | 105 | // Store all $conf['config'] |
106 | foreach ($conf['config'] as $key => $value) { | 106 | foreach ($conf['config'] as $key => $value) { |
107 | $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL; | 107 | $configStr .= '$GLOBALS[\'config\'][\'' |
108 | . $key | ||
109 | .'\'] = ' | ||
110 | .var_export($conf['config'][$key], true).';' | ||
111 | . PHP_EOL; | ||
108 | } | 112 | } |
109 | 113 | ||
110 | if (isset($conf['plugins'])) { | 114 | if (isset($conf['plugins'])) { |
111 | foreach ($conf['plugins'] as $key => $value) { | 115 | foreach ($conf['plugins'] as $key => $value) { |
112 | $configStr .= '$GLOBALS[\'plugins\'][\''. $key .'\'] = '.var_export($conf['plugins'][$key], true).';'. PHP_EOL; | 116 | $configStr .= '$GLOBALS[\'plugins\'][\'' |
117 | . $key | ||
118 | .'\'] = ' | ||
119 | .var_export($conf['plugins'][$key], true).';' | ||
120 | . PHP_EOL; | ||
113 | } | 121 | } |
114 | } | 122 | } |
115 | 123 | ||
@@ -806,7 +806,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
806 | $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']); | 806 | $params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']); |
807 | } | 807 | } |
808 | 808 | ||
809 | unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different) | 809 | // We also remove page (keeping the same page has no sense, since the |
810 | // results are different) | ||
811 | unset($params['page']); | ||
812 | |||
810 | header('Location: ?'.http_build_query($params)); | 813 | header('Location: ?'.http_build_query($params)); |
811 | exit; | 814 | exit; |
812 | } | 815 | } |
@@ -837,7 +840,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
837 | unset($params['searchtags']); | 840 | unset($params['searchtags']); |
838 | } | 841 | } |
839 | 842 | ||
840 | unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different) | 843 | // We also remove page (keeping the same page has no sense, since |
844 | // the results are different) | ||
845 | unset($params['page']); | ||
841 | } | 846 | } |
842 | header('Location: ?'.http_build_query($params)); | 847 | header('Location: ?'.http_build_query($params)); |
843 | exit; | 848 | exit; |
@@ -954,15 +959,26 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
954 | } | 959 | } |
955 | 960 | ||
956 | // Make sure old password is correct. | 961 | // Make sure old password is correct. |
957 | $oldhash = sha1($_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt')); | 962 | $oldhash = sha1( |
958 | if ($oldhash!= $conf->get('credentials.hash')) { | 963 | $_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt') |
959 | echo '<script>alert("'. t('The old password is not correct.') .'");document.location=\'?do=changepasswd\';</script>'; | 964 | ); |
965 | if ($oldhash != $conf->get('credentials.hash')) { | ||
966 | echo '<script>alert("' | ||
967 | . t('The old password is not correct.') | ||
968 | .'");document.location=\'?do=changepasswd\';</script>'; | ||
960 | exit; | 969 | exit; |
961 | } | 970 | } |
962 | // Save new password | 971 | // Save new password |
963 | // Salt renders rainbow-tables attacks useless. | 972 | // Salt renders rainbow-tables attacks useless. |
964 | $conf->set('credentials.salt', sha1(uniqid('', true) .'_'. mt_rand())); | 973 | $conf->set('credentials.salt', sha1(uniqid('', true) .'_'. mt_rand())); |
965 | $conf->set('credentials.hash', sha1($_POST['setpassword'] . $conf->get('credentials.login') . $conf->get('credentials.salt'))); | 974 | $conf->set( |
975 | 'credentials.hash', | ||
976 | sha1( | ||
977 | $_POST['setpassword'] | ||
978 | . $conf->get('credentials.login') | ||
979 | . $conf->get('credentials.salt') | ||
980 | ) | ||
981 | ); | ||
966 | try { | 982 | try { |
967 | $conf->write($loginManager->isLoggedIn()); | 983 | $conf->write($loginManager->isLoggedIn()); |
968 | } catch (Exception $e) { | 984 | } catch (Exception $e) { |
@@ -1015,7 +1031,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1015 | && $thumbnailsMode !== $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) | 1031 | && $thumbnailsMode !== $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) |
1016 | ) { | 1032 | ) { |
1017 | $_SESSION['warnings'][] = t( | 1033 | $_SESSION['warnings'][] = t( |
1018 | 'You have enabled or changed thumbnails mode. <a href="?do=thumbs_update">Please synchronize them</a>.' | 1034 | 'You have enabled or changed thumbnails mode. ' |
1035 | .'<a href="?do=thumbs_update">Please synchronize them</a>.' | ||
1019 | ); | 1036 | ); |
1020 | } | 1037 | } |
1021 | $conf->set('thumbnails.mode', $thumbnailsMode); | 1038 | $conf->set('thumbnails.mode', $thumbnailsMode); |
@@ -1296,7 +1313,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1296 | $description = empty($_GET['description']) ? '' : escape($_GET['description']); | 1313 | $description = empty($_GET['description']) ? '' : escape($_GET['description']); |
1297 | $tags = empty($_GET['tags']) ? '' : escape($_GET['tags']); | 1314 | $tags = empty($_GET['tags']) ? '' : escape($_GET['tags']); |
1298 | $private = !empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0; | 1315 | $private = !empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0; |
1299 | // If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.) | 1316 | |
1317 | // If this is an HTTP(S) link, we try go get the page to extract | ||
1318 | // the title (otherwise we will to straight to the edit form.) | ||
1300 | if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { | 1319 | if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { |
1301 | // Short timeout to keep the application responsive | 1320 | // Short timeout to keep the application responsive |
1302 | // The callback will fill $charset and $title with data from the downloaded page. | 1321 | // The callback will fill $charset and $title with data from the downloaded page. |
@@ -1514,7 +1533,11 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager, | |||
1514 | ); | 1533 | ); |
1515 | 1534 | ||
1516 | // TODO: do not handle exceptions/errors in JS. | 1535 | // TODO: do not handle exceptions/errors in JS. |
1517 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do='. Router::$PAGE_PLUGINSADMIN .'\';</script>'; | 1536 | echo '<script>alert("' |
1537 | . $e->getMessage() | ||
1538 | .'");document.location=\'?do=' | ||
1539 | . Router::$PAGE_PLUGINSADMIN | ||
1540 | .'\';</script>'; | ||
1518 | exit; | 1541 | exit; |
1519 | } | 1542 | } |
1520 | header('Location: ?do='. Router::$PAGE_PLUGINSADMIN); | 1543 | header('Location: ?do='. Router::$PAGE_PLUGINSADMIN); |
@@ -1749,7 +1772,8 @@ function install($conf, $sessionManager, $loginManager) | |||
1749 | // This part makes sure sessions works correctly. | 1772 | // This part makes sure sessions works correctly. |
1750 | // (Because on some hosts, session.save_path may not be set correctly, | 1773 | // (Because on some hosts, session.save_path may not be set correctly, |
1751 | // or we may not have write access to it.) | 1774 | // or we may not have write access to it.) |
1752 | if (isset($_GET['test_session']) && ( !isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested']!='Working')) { | 1775 | if (isset($_GET['test_session']) |
1776 | && ( !isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested']!='Working')) { | ||
1753 | // Step 2: Check if data in session is correct. | 1777 | // Step 2: Check if data in session is correct. |
1754 | $msg = t( | 1778 | $msg = t( |
1755 | '<pre>Sessions do not seem to work correctly on your server.<br>'. | 1779 | '<pre>Sessions do not seem to work correctly on your server.<br>'. |
@@ -1817,7 +1841,10 @@ function install($conf, $sessionManager, $loginManager) | |||
1817 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?\';</script>'; | 1841 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?\';</script>'; |
1818 | exit; | 1842 | exit; |
1819 | } | 1843 | } |
1820 | echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>'; | 1844 | echo '<script>alert(' |
1845 | .'"Shaarli is now configured. ' | ||
1846 | .'Please enter your login/password and start shaaring your links!"' | ||
1847 | .');document.location=\'?do=login\';</script>'; | ||
1821 | exit; | 1848 | exit; |
1822 | } | 1849 | } |
1823 | 1850 | ||
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index bdbc719b..ca520d15 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php | |||
@@ -108,10 +108,10 @@ function hook_demo_plugin_render_header($data) | |||
108 | * ], | 108 | * ], |
109 | * ] | 109 | * ] |
110 | * This example renders as: | 110 | * This example renders as: |
111 | * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value"> | 111 | * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value"> |
112 | * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value"> | 112 | * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value"> |
113 | * <input input-2-attribute-1="input 2 attribute 1 value"> | 113 | * <input input-2-attribute-1="input 2 attribute 1 value"> |
114 | * </form> | 114 | * </form> |
115 | */ | 115 | */ |
116 | $form = array( | 116 | $form = array( |
117 | 'attr' => array( | 117 | 'attr' => array( |
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 | /** |