aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/Base64Url.php34
-rw-r--r--application/CachedPage.php4
-rw-r--r--application/PageBuilder.php2
-rw-r--r--application/api/ApiUtils.php12
-rw-r--r--application/config/ConfigIO.php6
-rw-r--r--application/config/ConfigJson.php6
-rw-r--r--application/config/ConfigPhp.php6
-rw-r--r--docker/development/nginx.conf9
-rw-r--r--docker/production/nginx.conf9
-rw-r--r--docker/production/stable/nginx.conf9
-rw-r--r--index.php2
-rw-r--r--plugins/wallabag/WallabagInstance.php2
-rw-r--r--tests/Url/UrlTest.php8
-rw-r--r--tests/api/ApiUtilsTest.php15
-rw-r--r--tests/plugins/PluginAddlinkTest.php10
-rw-r--r--tests/plugins/PluginArchiveorgTest.php10
-rw-r--r--tests/plugins/PluginIssoTest.php14
-rw-r--r--tests/plugins/PluginMarkdownTest.php20
-rw-r--r--tests/plugins/PluginPlayvideosTest.php6
-rw-r--r--tests/plugins/PluginPubsubhubbubTest.php6
-rw-r--r--tests/plugins/PluginQrcodeTest.php (renamed from tests/plugins/PlugQrcodeTest.php)12
-rw-r--r--tests/plugins/PluginReadityourselfTest.php10
-rw-r--r--tests/plugins/PluginWallabagTest.php8
-rw-r--r--tests/plugins/WallabagInstanceTest.php8
24 files changed, 141 insertions, 87 deletions
diff --git a/application/Base64Url.php b/application/Base64Url.php
new file mode 100644
index 00000000..61590e43
--- /dev/null
+++ b/application/Base64Url.php
@@ -0,0 +1,34 @@
1<?php
2
3namespace Shaarli;
4
5
6/**
7 * URL-safe Base64 operations
8 *
9 * @see https://en.wikipedia.org/wiki/Base64#URL_applications
10 */
11class Base64Url
12{
13 /**
14 * Base64Url-encodes data
15 *
16 * @param string $data Data to encode
17 *
18 * @return string Base64Url-encoded data
19 */
20 public static function encode($data) {
21 return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
22 }
23
24 /**
25 * Decodes Base64Url-encoded data
26 *
27 * @param string $data Data to decode
28 *
29 * @return string Decoded data
30 */
31 public static function decode($data) {
32 return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
33 }
34}
diff --git a/application/CachedPage.php b/application/CachedPage.php
index 5087d0c4..e11cc52d 100644
--- a/application/CachedPage.php
+++ b/application/CachedPage.php
@@ -7,9 +7,6 @@ class CachedPage
7 // Directory containing page caches 7 // Directory containing page caches
8 private $cacheDir; 8 private $cacheDir;
9 9
10 // Full URL of the page to cache -typically the value returned by pageUrl()
11 private $url;
12
13 // Should this URL be cached (boolean)? 10 // Should this URL be cached (boolean)?
14 private $shouldBeCached; 11 private $shouldBeCached;
15 12
@@ -27,7 +24,6 @@ class CachedPage
27 { 24 {
28 // TODO: check write access to the cache directory 25 // TODO: check write access to the cache directory
29 $this->cacheDir = $cacheDir; 26 $this->cacheDir = $cacheDir;
30 $this->url = $url;
31 $this->filename = $this->cacheDir.'/'.sha1($url).'.cache'; 27 $this->filename = $this->cacheDir.'/'.sha1($url).'.cache';
32 $this->shouldBeCached = $shouldBeCached; 28 $this->shouldBeCached = $shouldBeCached;
33 } 29 }
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index 32c7f9f1..544aba7c 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -25,7 +25,7 @@ class PageBuilder
25 * 25 *
26 * @param ConfigManager $conf Configuration Manager instance (reference). 26 * @param ConfigManager $conf Configuration Manager instance (reference).
27 */ 27 */
28 function __construct(&$conf) 28 public function __construct(&$conf)
29 { 29 {
30 $this->tpl = false; 30 $this->tpl = false;
31 $this->conf = $conf; 31 $this->conf = $conf;
diff --git a/application/api/ApiUtils.php b/application/api/ApiUtils.php
index fbb1e72f..a419c396 100644
--- a/application/api/ApiUtils.php
+++ b/application/api/ApiUtils.php
@@ -1,13 +1,11 @@
1<?php 1<?php
2
3namespace Shaarli\Api; 2namespace Shaarli\Api;
4 3
4use Shaarli\Base64Url;
5use Shaarli\Api\Exceptions\ApiAuthorizationException; 5use Shaarli\Api\Exceptions\ApiAuthorizationException;
6 6
7/** 7/**
8 * Class ApiUtils 8 * REST API utilities
9 *
10 * Utility functions for the API.
11 */ 9 */
12class ApiUtils 10class ApiUtils
13{ 11{
@@ -26,17 +24,17 @@ class ApiUtils
26 throw new ApiAuthorizationException('Malformed JWT token'); 24 throw new ApiAuthorizationException('Malformed JWT token');
27 } 25 }
28 26
29 $genSign = hash_hmac('sha512', $parts[0] .'.'. $parts[1], $secret); 27 $genSign = Base64Url::encode(hash_hmac('sha512', $parts[0] .'.'. $parts[1], $secret, true));
30 if ($parts[2] != $genSign) { 28 if ($parts[2] != $genSign) {
31 throw new ApiAuthorizationException('Invalid JWT signature'); 29 throw new ApiAuthorizationException('Invalid JWT signature');
32 } 30 }
33 31
34 $header = json_decode(base64_decode($parts[0])); 32 $header = json_decode(Base64Url::decode($parts[0]));
35 if ($header === null) { 33 if ($header === null) {
36 throw new ApiAuthorizationException('Invalid JWT header'); 34 throw new ApiAuthorizationException('Invalid JWT header');
37 } 35 }
38 36
39 $payload = json_decode(base64_decode($parts[1])); 37 $payload = json_decode(Base64Url::decode($parts[1]));
40 if ($payload === null) { 38 if ($payload === null) {
41 throw new ApiAuthorizationException('Invalid JWT payload'); 39 throw new ApiAuthorizationException('Invalid JWT payload');
42 } 40 }
diff --git a/application/config/ConfigIO.php b/application/config/ConfigIO.php
index 2b68fe6a..be78b1c7 100644
--- a/application/config/ConfigIO.php
+++ b/application/config/ConfigIO.php
@@ -14,7 +14,7 @@ interface ConfigIO
14 * 14 *
15 * @return array All configuration in an array. 15 * @return array All configuration in an array.
16 */ 16 */
17 function read($filepath); 17 public function read($filepath);
18 18
19 /** 19 /**
20 * Write configuration. 20 * Write configuration.
@@ -22,12 +22,12 @@ interface ConfigIO
22 * @param string $filepath Config file absolute path. 22 * @param string $filepath Config file absolute path.
23 * @param array $conf All configuration in an array. 23 * @param array $conf All configuration in an array.
24 */ 24 */
25 function write($filepath, $conf); 25 public function write($filepath, $conf);
26 26
27 /** 27 /**
28 * Get config file extension according to config type. 28 * Get config file extension according to config type.
29 * 29 *
30 * @return string Config file extension. 30 * @return string Config file extension.
31 */ 31 */
32 function getExtension(); 32 public function getExtension();
33} 33}
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php
index 30007eb4..6b5d73f1 100644
--- a/application/config/ConfigJson.php
+++ b/application/config/ConfigJson.php
@@ -10,7 +10,7 @@ class ConfigJson implements ConfigIO
10 /** 10 /**
11 * @inheritdoc 11 * @inheritdoc
12 */ 12 */
13 function read($filepath) 13 public function read($filepath)
14 { 14 {
15 if (! is_readable($filepath)) { 15 if (! is_readable($filepath)) {
16 return array(); 16 return array();
@@ -29,7 +29,7 @@ class ConfigJson implements ConfigIO
29 /** 29 /**
30 * @inheritdoc 30 * @inheritdoc
31 */ 31 */
32 function write($filepath, $conf) 32 public function write($filepath, $conf)
33 { 33 {
34 // JSON_PRETTY_PRINT is available from PHP 5.4. 34 // JSON_PRETTY_PRINT is available from PHP 5.4.
35 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; 35 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
@@ -46,7 +46,7 @@ class ConfigJson implements ConfigIO
46 /** 46 /**
47 * @inheritdoc 47 * @inheritdoc
48 */ 48 */
49 function getExtension() 49 public function getExtension()
50 { 50 {
51 return '.json.php'; 51 return '.json.php';
52 } 52 }
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php
index 2eb68d80..d7fd4baf 100644
--- a/application/config/ConfigPhp.php
+++ b/application/config/ConfigPhp.php
@@ -72,7 +72,7 @@ class ConfigPhp implements ConfigIO
72 /** 72 /**
73 * @inheritdoc 73 * @inheritdoc
74 */ 74 */
75 function read($filepath) 75 public function read($filepath)
76 { 76 {
77 if (! file_exists($filepath) || ! is_readable($filepath)) { 77 if (! file_exists($filepath) || ! is_readable($filepath)) {
78 return array(); 78 return array();
@@ -92,7 +92,7 @@ class ConfigPhp implements ConfigIO
92 /** 92 /**
93 * @inheritdoc 93 * @inheritdoc
94 */ 94 */
95 function write($filepath, $conf) 95 public function write($filepath, $conf)
96 { 96 {
97 $configStr = '<?php '. PHP_EOL; 97 $configStr = '<?php '. PHP_EOL;
98 foreach (self::$ROOT_KEYS as $key) { 98 foreach (self::$ROOT_KEYS as $key) {
@@ -126,7 +126,7 @@ class ConfigPhp implements ConfigIO
126 /** 126 /**
127 * @inheritdoc 127 * @inheritdoc
128 */ 128 */
129 function getExtension() 129 public function getExtension()
130 { 130 {
131 return '.php'; 131 return '.php';
132 } 132 }
diff --git a/docker/development/nginx.conf b/docker/development/nginx.conf
index ac0c6c61..79c45bfe 100644
--- a/docker/development/nginx.conf
+++ b/docker/development/nginx.conf
@@ -56,7 +56,16 @@ http {
56 alias /var/www/shaarli/images/favicon.ico; 56 alias /var/www/shaarli/images/favicon.ico;
57 } 57 }
58 58
59 location / {
60 # Slim - rewrite URLs
61 try_files $uri /index.php$is_args$args;
62 }
63
59 location ~ (index)\.php$ { 64 location ~ (index)\.php$ {
65 # Slim - split URL path into (script_filename, path_info)
66 try_files $uri =404;
67 fastcgi_split_path_info ^(.+\.php)(/.+)$;
68
60 # filter and proxy PHP requests to PHP-FPM 69 # filter and proxy PHP requests to PHP-FPM
61 fastcgi_pass unix:/var/run/php5-fpm.sock; 70 fastcgi_pass unix:/var/run/php5-fpm.sock;
62 fastcgi_index index.php; 71 fastcgi_index index.php;
diff --git a/docker/production/nginx.conf b/docker/production/nginx.conf
index 5ffa02d0..e8754d9b 100644
--- a/docker/production/nginx.conf
+++ b/docker/production/nginx.conf
@@ -48,7 +48,16 @@ http {
48 alias /var/www/shaarli/images/favicon.ico; 48 alias /var/www/shaarli/images/favicon.ico;
49 } 49 }
50 50
51 location / {
52 # Slim - rewrite URLs
53 try_files $uri /index.php$is_args$args;
54 }
55
51 location ~ (index)\.php$ { 56 location ~ (index)\.php$ {
57 # Slim - split URL path into (script_filename, path_info)
58 try_files $uri =404;
59 fastcgi_split_path_info ^(.+\.php)(/.+)$;
60
52 # filter and proxy PHP requests to PHP-FPM 61 # filter and proxy PHP requests to PHP-FPM
53 fastcgi_pass unix:/var/run/php5-fpm.sock; 62 fastcgi_pass unix:/var/run/php5-fpm.sock;
54 fastcgi_index index.php; 63 fastcgi_index index.php;
diff --git a/docker/production/stable/nginx.conf b/docker/production/stable/nginx.conf
index 5ffa02d0..e8754d9b 100644
--- a/docker/production/stable/nginx.conf
+++ b/docker/production/stable/nginx.conf
@@ -48,7 +48,16 @@ http {
48 alias /var/www/shaarli/images/favicon.ico; 48 alias /var/www/shaarli/images/favicon.ico;
49 } 49 }
50 50
51 location / {
52 # Slim - rewrite URLs
53 try_files $uri /index.php$is_args$args;
54 }
55
51 location ~ (index)\.php$ { 56 location ~ (index)\.php$ {
57 # Slim - split URL path into (script_filename, path_info)
58 try_files $uri =404;
59 fastcgi_split_path_info ^(.+\.php)(/.+)$;
60
52 # filter and proxy PHP requests to PHP-FPM 61 # filter and proxy PHP requests to PHP-FPM
53 fastcgi_pass unix:/var/run/php5-fpm.sock; 62 fastcgi_pass unix:/var/run/php5-fpm.sock;
54 fastcgi_index index.php; 63 fastcgi_index index.php;
diff --git a/index.php b/index.php
index 14754269..e553d1dd 100644
--- a/index.php
+++ b/index.php
@@ -618,7 +618,7 @@ function showDailyRSS($conf) {
618 $tpl->assign('links', $links); 618 $tpl->assign('links', $links);
619 $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS))); 619 $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS)));
620 $tpl->assign('hide_timestamps', $conf->get('privacy.hide_timestamps', false)); 620 $tpl->assign('hide_timestamps', $conf->get('privacy.hide_timestamps', false));
621 $html = $tpl->draw('dailyrss', $return_string=true); 621 $html = $tpl->draw('dailyrss', true);
622 622
623 echo $html . PHP_EOL; 623 echo $html . PHP_EOL;
624 } 624 }
diff --git a/plugins/wallabag/WallabagInstance.php b/plugins/wallabag/WallabagInstance.php
index 72cc2e5e..eb8ab618 100644
--- a/plugins/wallabag/WallabagInstance.php
+++ b/plugins/wallabag/WallabagInstance.php
@@ -35,7 +35,7 @@ class WallabagInstance
35 */ 35 */
36 private $apiVersion; 36 private $apiVersion;
37 37
38 function __construct($instance, $version) 38 public function __construct($instance, $version)
39 { 39 {
40 if ($this->isVersionAllowed($version)) { 40 if ($this->isVersionAllowed($version)) {
41 $this->apiVersion = self::$wallabagVersions[$version]; 41 $this->apiVersion = self::$wallabagVersions[$version];
diff --git a/tests/Url/UrlTest.php b/tests/Url/UrlTest.php
index 05862372..aa2f2234 100644
--- a/tests/Url/UrlTest.php
+++ b/tests/Url/UrlTest.php
@@ -157,7 +157,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
157 /** 157 /**
158 * Test add trailing slash. 158 * Test add trailing slash.
159 */ 159 */
160 function testAddTrailingSlash() 160 public function testAddTrailingSlash()
161 { 161 {
162 $strOn = 'http://randomstr.com/test/'; 162 $strOn = 'http://randomstr.com/test/';
163 $strOff = 'http://randomstr.com/test'; 163 $strOff = 'http://randomstr.com/test';
@@ -168,7 +168,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
168 /** 168 /**
169 * Test valid HTTP url. 169 * Test valid HTTP url.
170 */ 170 */
171 function testUrlIsHttp() 171 public function testUrlIsHttp()
172 { 172 {
173 $url = new Url(self::$baseUrl); 173 $url = new Url(self::$baseUrl);
174 $this->assertTrue($url->isHttp()); 174 $this->assertTrue($url->isHttp());
@@ -177,7 +177,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
177 /** 177 /**
178 * Test non HTTP url. 178 * Test non HTTP url.
179 */ 179 */
180 function testUrlIsNotHttp() 180 public function testUrlIsNotHttp()
181 { 181 {
182 $url = new Url('ftp://save.tld/mysave'); 182 $url = new Url('ftp://save.tld/mysave');
183 $this->assertFalse($url->isHttp()); 183 $this->assertFalse($url->isHttp());
@@ -186,7 +186,7 @@ class UrlTest extends PHPUnit_Framework_TestCase
186 /** 186 /**
187 * Test International Domain Name to ASCII conversion 187 * Test International Domain Name to ASCII conversion
188 */ 188 */
189 function testIdnToAscii() 189 public function testIdnToAscii()
190 { 190 {
191 $ind = 'http://www.académie-française.fr/'; 191 $ind = 'http://www.académie-française.fr/';
192 $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/'; 192 $expected = 'http://www.xn--acadmie-franaise-npb1a.fr/';
diff --git a/tests/api/ApiUtilsTest.php b/tests/api/ApiUtilsTest.php
index 10da1459..4b2fa3b2 100644
--- a/tests/api/ApiUtilsTest.php
+++ b/tests/api/ApiUtilsTest.php
@@ -2,6 +2,9 @@
2 2
3namespace Shaarli\Api; 3namespace Shaarli\Api;
4 4
5use Shaarli\Base64Url;
6
7
5/** 8/**
6 * Class ApiUtilsTest 9 * Class ApiUtilsTest
7 */ 10 */
@@ -24,14 +27,14 @@ class ApiUtilsTest extends \PHPUnit_Framework_TestCase
24 */ 27 */
25 public static function generateValidJwtToken($secret) 28 public static function generateValidJwtToken($secret)
26 { 29 {
27 $header = base64_encode('{ 30 $header = Base64Url::encode('{
28 "typ": "JWT", 31 "typ": "JWT",
29 "alg": "HS512" 32 "alg": "HS512"
30 }'); 33 }');
31 $payload = base64_encode('{ 34 $payload = Base64Url::encode('{
32 "iat": '. time() .' 35 "iat": '. time() .'
33 }'); 36 }');
34 $signature = hash_hmac('sha512', $header .'.'. $payload , $secret); 37 $signature = Base64Url::encode(hash_hmac('sha512', $header .'.'. $payload , $secret, true));
35 return $header .'.'. $payload .'.'. $signature; 38 return $header .'.'. $payload .'.'. $signature;
36 } 39 }
37 40
@@ -46,9 +49,9 @@ class ApiUtilsTest extends \PHPUnit_Framework_TestCase
46 */ 49 */
47 public static function generateCustomJwtToken($header, $payload, $secret) 50 public static function generateCustomJwtToken($header, $payload, $secret)
48 { 51 {
49 $header = base64_encode($header); 52 $header = Base64Url::encode($header);
50 $payload = base64_encode($payload); 53 $payload = Base64Url::encode($payload);
51 $signature = hash_hmac('sha512', $header . '.' . $payload, $secret); 54 $signature = Base64Url::encode(hash_hmac('sha512', $header . '.' . $payload, $secret, true));
52 return $header . '.' . $payload . '.' . $signature; 55 return $header . '.' . $payload . '.' . $signature;
53 } 56 }
54 57
diff --git a/tests/plugins/PluginAddlinkTest.php b/tests/plugins/PluginAddlinkTest.php
index a2f25bec..b77fe12a 100644
--- a/tests/plugins/PluginAddlinkTest.php
+++ b/tests/plugins/PluginAddlinkTest.php
@@ -16,7 +16,7 @@ class PluginAddlinkTest extends PHPUnit_Framework_TestCase
16 /** 16 /**
17 * Reset plugin path. 17 * Reset plugin path.
18 */ 18 */
19 function setUp() 19 public function setUp()
20 { 20 {
21 PluginManager::$PLUGINS_PATH = 'plugins'; 21 PluginManager::$PLUGINS_PATH = 'plugins';
22 } 22 }
@@ -24,7 +24,7 @@ class PluginAddlinkTest extends PHPUnit_Framework_TestCase
24 /** 24 /**
25 * Test render_header hook while logged in. 25 * Test render_header hook while logged in.
26 */ 26 */
27 function testAddlinkHeaderLoggedIn() 27 public function testAddlinkHeaderLoggedIn()
28 { 28 {
29 $str = 'stuff'; 29 $str = 'stuff';
30 $data = array($str => $str); 30 $data = array($str => $str);
@@ -46,7 +46,7 @@ class PluginAddlinkTest extends PHPUnit_Framework_TestCase
46 /** 46 /**
47 * Test render_header hook while logged out. 47 * Test render_header hook while logged out.
48 */ 48 */
49 function testAddlinkHeaderLoggedOut() 49 public function testAddlinkHeaderLoggedOut()
50 { 50 {
51 $str = 'stuff'; 51 $str = 'stuff';
52 $data = array($str => $str); 52 $data = array($str => $str);
@@ -61,7 +61,7 @@ class PluginAddlinkTest extends PHPUnit_Framework_TestCase
61 /** 61 /**
62 * Test render_includes hook while logged in. 62 * Test render_includes hook while logged in.
63 */ 63 */
64 function testAddlinkIncludesLoggedIn() 64 public function testAddlinkIncludesLoggedIn()
65 { 65 {
66 $str = 'stuff'; 66 $str = 'stuff';
67 $data = array($str => $str); 67 $data = array($str => $str);
@@ -86,7 +86,7 @@ class PluginAddlinkTest extends PHPUnit_Framework_TestCase
86 * Test render_includes hook. 86 * Test render_includes hook.
87 * Should not affect css files while logged out. 87 * Should not affect css files while logged out.
88 */ 88 */
89 function testAddlinkIncludesLoggedOut() 89 public function testAddlinkIncludesLoggedOut()
90 { 90 {
91 $str = 'stuff'; 91 $str = 'stuff';
92 $data = array($str => $str); 92 $data = array($str => $str);
diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php
index 4daa4c9d..fecd5f2c 100644
--- a/tests/plugins/PluginArchiveorgTest.php
+++ b/tests/plugins/PluginArchiveorgTest.php
@@ -15,7 +15,7 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase
15 /** 15 /**
16 * Reset plugin path 16 * Reset plugin path
17 */ 17 */
18 function setUp() 18 public function setUp()
19 { 19 {
20 PluginManager::$PLUGINS_PATH = 'plugins'; 20 PluginManager::$PLUGINS_PATH = 'plugins';
21 } 21 }
@@ -23,7 +23,7 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase
23 /** 23 /**
24 * Test render_linklist hook on external links. 24 * Test render_linklist hook on external links.
25 */ 25 */
26 function testArchiveorgLinklistOnExternalLinks() 26 public function testArchiveorgLinklistOnExternalLinks()
27 { 27 {
28 $str = 'http://randomstr.com/test'; 28 $str = 'http://randomstr.com/test';
29 29
@@ -48,13 +48,12 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase
48 // plugin data 48 // plugin data
49 $this->assertEquals(1, count($link['link_plugin'])); 49 $this->assertEquals(1, count($link['link_plugin']));
50 $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); 50 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
51
52 } 51 }
53 52
54 /** 53 /**
55 * Test render_linklist hook on internal links. 54 * Test render_linklist hook on internal links.
56 */ 55 */
57 function testArchiveorgLinklistOnInternalLinks() 56 public function testArchiveorgLinklistOnInternalLinks()
58 { 57 {
59 $internalLink1 = 'http://shaarli.shaarli/?qvMAqg'; 58 $internalLink1 = 'http://shaarli.shaarli/?qvMAqg';
60 $internalLinkRealURL1 = '?qvMAqg'; 59 $internalLinkRealURL1 = '?qvMAqg';
@@ -101,7 +100,6 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase
101 ) 100 )
102 ); 101 );
103 102
104
105 $data = hook_archiveorg_render_linklist($data); 103 $data = hook_archiveorg_render_linklist($data);
106 104
107 // Case n°1: first link type, public 105 // Case n°1: first link type, public
@@ -136,7 +134,5 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase
136 $link = $data['links'][5]; 134 $link = $data['links'][5];
137 135
138 $this->assertArrayNotHasKey('link_plugin', $link); 136 $this->assertArrayNotHasKey('link_plugin', $link);
139
140 } 137 }
141
142} 138}
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php
index 6b7904dd..03def208 100644
--- a/tests/plugins/PluginIssoTest.php
+++ b/tests/plugins/PluginIssoTest.php
@@ -12,7 +12,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
12 /** 12 /**
13 * Reset plugin path 13 * Reset plugin path
14 */ 14 */
15 function setUp() 15 public function setUp()
16 { 16 {
17 PluginManager::$PLUGINS_PATH = 'plugins'; 17 PluginManager::$PLUGINS_PATH = 'plugins';
18 } 18 }
@@ -20,7 +20,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
20 /** 20 /**
21 * Test Isso init without errors. 21 * Test Isso init without errors.
22 */ 22 */
23 function testWallabagInitNoError() 23 public function testWallabagInitNoError()
24 { 24 {
25 $conf = new ConfigManager(''); 25 $conf = new ConfigManager('');
26 $conf->set('plugins.ISSO_SERVER', 'value'); 26 $conf->set('plugins.ISSO_SERVER', 'value');
@@ -31,7 +31,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
31 /** 31 /**
32 * Test Isso init with errors. 32 * Test Isso init with errors.
33 */ 33 */
34 function testWallabagInitError() 34 public function testWallabagInitError()
35 { 35 {
36 $conf = new ConfigManager(''); 36 $conf = new ConfigManager('');
37 $errors = isso_init($conf); 37 $errors = isso_init($conf);
@@ -41,7 +41,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
41 /** 41 /**
42 * Test render_linklist hook with valid settings to display the comment form. 42 * Test render_linklist hook with valid settings to display the comment form.
43 */ 43 */
44 function testIssoDisplayed() 44 public function testIssoDisplayed()
45 { 45 {
46 $conf = new ConfigManager(''); 46 $conf = new ConfigManager('');
47 $conf->set('plugins.ISSO_SERVER', 'value'); 47 $conf->set('plugins.ISSO_SERVER', 'value');
@@ -81,7 +81,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
81 /** 81 /**
82 * Test isso plugin when multiple links are displayed (shouldn't be displayed). 82 * Test isso plugin when multiple links are displayed (shouldn't be displayed).
83 */ 83 */
84 function testIssoMultipleLinks() 84 public function testIssoMultipleLinks()
85 { 85 {
86 $conf = new ConfigManager(''); 86 $conf = new ConfigManager('');
87 $conf->set('plugins.ISSO_SERVER', 'value'); 87 $conf->set('plugins.ISSO_SERVER', 'value');
@@ -113,7 +113,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
113 /** 113 /**
114 * Test isso plugin when using search (shouldn't be displayed). 114 * Test isso plugin when using search (shouldn't be displayed).
115 */ 115 */
116 function testIssoNotDisplayedWhenSearch() 116 public function testIssoNotDisplayedWhenSearch()
117 { 117 {
118 $conf = new ConfigManager(''); 118 $conf = new ConfigManager('');
119 $conf->set('plugins.ISSO_SERVER', 'value'); 119 $conf->set('plugins.ISSO_SERVER', 'value');
@@ -141,7 +141,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
141 /** 141 /**
142 * Test isso plugin without server configuration (shouldn't be displayed). 142 * Test isso plugin without server configuration (shouldn't be displayed).
143 */ 143 */
144 function testIssoWithoutConf() 144 public function testIssoWithoutConf()
145 { 145 {
146 $data = 'abc'; 146 $data = 'abc';
147 $conf = new ConfigManager(''); 147 $conf = new ConfigManager('');
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index 17ef2280..d359b2a1 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -16,7 +16,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
16 /** 16 /**
17 * Reset plugin path 17 * Reset plugin path
18 */ 18 */
19 function setUp() 19 public function setUp()
20 { 20 {
21 PluginManager::$PLUGINS_PATH = 'plugins'; 21 PluginManager::$PLUGINS_PATH = 'plugins';
22 } 22 }
@@ -25,7 +25,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
25 * Test render_linklist hook. 25 * Test render_linklist hook.
26 * Only check that there is basic markdown rendering. 26 * Only check that there is basic markdown rendering.
27 */ 27 */
28 function testMarkdownLinklist() 28 public function testMarkdownLinklist()
29 { 29 {
30 $markdown = '# My title' . PHP_EOL . 'Very interesting content.'; 30 $markdown = '# My title' . PHP_EOL . 'Very interesting content.';
31 $data = array( 31 $data = array(
@@ -45,7 +45,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
45 * Test render_daily hook. 45 * Test render_daily hook.
46 * Only check that there is basic markdown rendering. 46 * Only check that there is basic markdown rendering.
47 */ 47 */
48 function testMarkdownDaily() 48 public function testMarkdownDaily()
49 { 49 {
50 $markdown = '# My title' . PHP_EOL . 'Very interesting content.'; 50 $markdown = '# My title' . PHP_EOL . 'Very interesting content.';
51 $data = array( 51 $data = array(
@@ -69,7 +69,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
69 /** 69 /**
70 * Test reverse_text2clickable(). 70 * Test reverse_text2clickable().
71 */ 71 */
72 function testReverseText2clickable() 72 public function testReverseText2clickable()
73 { 73 {
74 $text = 'stuff http://hello.there/is=someone#here otherstuff'; 74 $text = 'stuff http://hello.there/is=someone#here otherstuff';
75 $clickableText = text2clickable($text, ''); 75 $clickableText = text2clickable($text, '');
@@ -80,7 +80,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
80 /** 80 /**
81 * Test reverse_nl2br(). 81 * Test reverse_nl2br().
82 */ 82 */
83 function testReverseNl2br() 83 public function testReverseNl2br()
84 { 84 {
85 $text = 'stuff' . PHP_EOL . 'otherstuff'; 85 $text = 'stuff' . PHP_EOL . 'otherstuff';
86 $processedText = nl2br($text); 86 $processedText = nl2br($text);
@@ -91,7 +91,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
91 /** 91 /**
92 * Test reverse_space2nbsp(). 92 * Test reverse_space2nbsp().
93 */ 93 */
94 function testReverseSpace2nbsp() 94 public function testReverseSpace2nbsp()
95 { 95 {
96 $text = ' stuff' . PHP_EOL . ' otherstuff and another'; 96 $text = ' stuff' . PHP_EOL . ' otherstuff and another';
97 $processedText = space2nbsp($text); 97 $processedText = space2nbsp($text);
@@ -102,7 +102,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
102 /** 102 /**
103 * Test sanitize_html(). 103 * Test sanitize_html().
104 */ 104 */
105 function testSanitizeHtml() 105 public function testSanitizeHtml()
106 { 106 {
107 $input = '< script src="js.js"/>'; 107 $input = '< script src="js.js"/>';
108 $input .= '< script attr>alert(\'xss\');</script>'; 108 $input .= '< script attr>alert(\'xss\');</script>';
@@ -119,7 +119,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
119 /** 119 /**
120 * Test the no markdown tag. 120 * Test the no markdown tag.
121 */ 121 */
122 function testNoMarkdownTag() 122 public function testNoMarkdownTag()
123 { 123 {
124 $str = 'All _work_ and `no play` makes Jack a *dull* boy.'; 124 $str = 'All _work_ and `no play` makes Jack a *dull* boy.';
125 $data = array( 125 $data = array(
@@ -158,7 +158,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
158 /** 158 /**
159 * Test that a close value to nomarkdown is not understand as nomarkdown (previous value `.nomarkdown`). 159 * Test that a close value to nomarkdown is not understand as nomarkdown (previous value `.nomarkdown`).
160 */ 160 */
161 function testNoMarkdownNotExcactlyMatching() 161 public function testNoMarkdownNotExcactlyMatching()
162 { 162 {
163 $str = 'All _work_ and `no play` makes Jack a *dull* boy.'; 163 $str = 'All _work_ and `no play` makes Jack a *dull* boy.';
164 $data = array( 164 $data = array(
@@ -176,7 +176,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
176 /** 176 /**
177 * Test hashtag links processed with markdown. 177 * Test hashtag links processed with markdown.
178 */ 178 */
179 function testMarkdownHashtagLinks() 179 public function testMarkdownHashtagLinks()
180 { 180 {
181 $md = file_get_contents('tests/plugins/resources/markdown.md'); 181 $md = file_get_contents('tests/plugins/resources/markdown.md');
182 $md = format_description($md); 182 $md = format_description($md);
diff --git a/tests/plugins/PluginPlayvideosTest.php b/tests/plugins/PluginPlayvideosTest.php
index be1ef774..29ad047f 100644
--- a/tests/plugins/PluginPlayvideosTest.php
+++ b/tests/plugins/PluginPlayvideosTest.php
@@ -16,7 +16,7 @@ class PluginPlayvideosTest extends PHPUnit_Framework_TestCase
16 /** 16 /**
17 * Reset plugin path 17 * Reset plugin path
18 */ 18 */
19 function setUp() 19 public function setUp()
20 { 20 {
21 PluginManager::$PLUGINS_PATH = 'plugins'; 21 PluginManager::$PLUGINS_PATH = 'plugins';
22 } 22 }
@@ -24,7 +24,7 @@ class PluginPlayvideosTest extends PHPUnit_Framework_TestCase
24 /** 24 /**
25 * Test render_linklist hook. 25 * Test render_linklist hook.
26 */ 26 */
27 function testPlayvideosHeader() 27 public function testPlayvideosHeader()
28 { 28 {
29 $str = 'stuff'; 29 $str = 'stuff';
30 $data = array($str => $str); 30 $data = array($str => $str);
@@ -43,7 +43,7 @@ class PluginPlayvideosTest extends PHPUnit_Framework_TestCase
43 /** 43 /**
44 * Test render_footer hook. 44 * Test render_footer hook.
45 */ 45 */
46 function testPlayvideosFooter() 46 public function testPlayvideosFooter()
47 { 47 {
48 $str = 'stuff'; 48 $str = 'stuff';
49 $data = array($str => $str); 49 $data = array($str => $str);
diff --git a/tests/plugins/PluginPubsubhubbubTest.php b/tests/plugins/PluginPubsubhubbubTest.php
index 24dd7a11..1bd87935 100644
--- a/tests/plugins/PluginPubsubhubbubTest.php
+++ b/tests/plugins/PluginPubsubhubbubTest.php
@@ -17,7 +17,7 @@ class PluginPubsubhubbubTest extends PHPUnit_Framework_TestCase
17 /** 17 /**
18 * Reset plugin path 18 * Reset plugin path
19 */ 19 */
20 function setUp() 20 public function setUp()
21 { 21 {
22 PluginManager::$PLUGINS_PATH = 'plugins'; 22 PluginManager::$PLUGINS_PATH = 'plugins';
23 } 23 }
@@ -25,7 +25,7 @@ class PluginPubsubhubbubTest extends PHPUnit_Framework_TestCase
25 /** 25 /**
26 * Test render_feed hook with an RSS feed. 26 * Test render_feed hook with an RSS feed.
27 */ 27 */
28 function testPubSubRssRenderFeed() 28 public function testPubSubRssRenderFeed()
29 { 29 {
30 $hub = 'http://domain.hub'; 30 $hub = 'http://domain.hub';
31 $conf = new ConfigManager(self::$configFile); 31 $conf = new ConfigManager(self::$configFile);
@@ -40,7 +40,7 @@ class PluginPubsubhubbubTest extends PHPUnit_Framework_TestCase
40 /** 40 /**
41 * Test render_feed hook with an ATOM feed. 41 * Test render_feed hook with an ATOM feed.
42 */ 42 */
43 function testPubSubAtomRenderFeed() 43 public function testPubSubAtomRenderFeed()
44 { 44 {
45 $hub = 'http://domain.hub'; 45 $hub = 'http://domain.hub';
46 $conf = new ConfigManager(self::$configFile); 46 $conf = new ConfigManager(self::$configFile);
diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PluginQrcodeTest.php
index 86dc7f29..211ee89c 100644
--- a/tests/plugins/PlugQrcodeTest.php
+++ b/tests/plugins/PluginQrcodeTest.php
@@ -1,29 +1,29 @@
1<?php 1<?php
2 2
3/** 3/**
4 * PlugQrcodeTest.php 4 * PluginQrcodeTest.php
5 */ 5 */
6 6
7require_once 'plugins/qrcode/qrcode.php'; 7require_once 'plugins/qrcode/qrcode.php';
8require_once 'application/Router.php'; 8require_once 'application/Router.php';
9 9
10/** 10/**
11 * Class PlugQrcodeTest 11 * Class PluginQrcodeTest
12 * Unit test for the QR-Code plugin 12 * Unit test for the QR-Code plugin
13 */ 13 */
14class PlugQrcodeTest extends PHPUnit_Framework_TestCase 14class PluginQrcodeTest extends PHPUnit_Framework_TestCase
15{ 15{
16 /** 16 /**
17 * Reset plugin path 17 * Reset plugin path
18 */ 18 */
19 function setUp() { 19 public function setUp() {
20 PluginManager::$PLUGINS_PATH = 'plugins'; 20 PluginManager::$PLUGINS_PATH = 'plugins';
21 } 21 }
22 22
23 /** 23 /**
24 * Test render_linklist hook. 24 * Test render_linklist hook.
25 */ 25 */
26 function testQrcodeLinklist() 26 public function testQrcodeLinklist()
27 { 27 {
28 $str = 'http://randomstr.com/test'; 28 $str = 'http://randomstr.com/test';
29 $data = array( 29 $data = array(
@@ -49,7 +49,7 @@ class PlugQrcodeTest extends PHPUnit_Framework_TestCase
49 /** 49 /**
50 * Test render_footer hook. 50 * Test render_footer hook.
51 */ 51 */
52 function testQrcodeFooter() 52 public function testQrcodeFooter()
53 { 53 {
54 $str = 'stuff'; 54 $str = 'stuff';
55 $data = array($str => $str); 55 $data = array($str => $str);
diff --git a/tests/plugins/PluginReadityourselfTest.php b/tests/plugins/PluginReadityourselfTest.php
index 532db146..30470ab7 100644
--- a/tests/plugins/PluginReadityourselfTest.php
+++ b/tests/plugins/PluginReadityourselfTest.php
@@ -15,7 +15,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
15 /** 15 /**
16 * Reset plugin path 16 * Reset plugin path
17 */ 17 */
18 function setUp() 18 public function setUp()
19 { 19 {
20 PluginManager::$PLUGINS_PATH = 'plugins'; 20 PluginManager::$PLUGINS_PATH = 'plugins';
21 } 21 }
@@ -23,7 +23,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
23 /** 23 /**
24 * Test Readityourself init without errors. 24 * Test Readityourself init without errors.
25 */ 25 */
26 function testReadityourselfInitNoError() 26 public function testReadityourselfInitNoError()
27 { 27 {
28 $conf = new ConfigManager(''); 28 $conf = new ConfigManager('');
29 $conf->set('plugins.READITYOUSELF_URL', 'value'); 29 $conf->set('plugins.READITYOUSELF_URL', 'value');
@@ -34,7 +34,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
34 /** 34 /**
35 * Test Readityourself init with errors. 35 * Test Readityourself init with errors.
36 */ 36 */
37 function testReadityourselfInitError() 37 public function testReadityourselfInitError()
38 { 38 {
39 $conf = new ConfigManager(''); 39 $conf = new ConfigManager('');
40 $errors = readityourself_init($conf); 40 $errors = readityourself_init($conf);
@@ -44,7 +44,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
44 /** 44 /**
45 * Test render_linklist hook. 45 * Test render_linklist hook.
46 */ 46 */
47 function testReadityourselfLinklist() 47 public function testReadityourselfLinklist()
48 { 48 {
49 $conf = new ConfigManager(''); 49 $conf = new ConfigManager('');
50 $conf->set('plugins.READITYOUSELF_URL', 'value'); 50 $conf->set('plugins.READITYOUSELF_URL', 'value');
@@ -72,7 +72,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
72 /** 72 /**
73 * Test without config: nothing should happened. 73 * Test without config: nothing should happened.
74 */ 74 */
75 function testReadityourselfLinklistWithoutConfig() 75 public function testReadityourselfLinklistWithoutConfig()
76 { 76 {
77 $conf = new ConfigManager(''); 77 $conf = new ConfigManager('');
78 $conf->set('plugins.READITYOUSELF_URL', null); 78 $conf->set('plugins.READITYOUSELF_URL', null);
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php
index 2c268cbd..30351f46 100644
--- a/tests/plugins/PluginWallabagTest.php
+++ b/tests/plugins/PluginWallabagTest.php
@@ -15,7 +15,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
15 /** 15 /**
16 * Reset plugin path 16 * Reset plugin path
17 */ 17 */
18 function setUp() 18 public function setUp()
19 { 19 {
20 PluginManager::$PLUGINS_PATH = 'plugins'; 20 PluginManager::$PLUGINS_PATH = 'plugins';
21 } 21 }
@@ -23,7 +23,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
23 /** 23 /**
24 * Test wallabag init without errors. 24 * Test wallabag init without errors.
25 */ 25 */
26 function testWallabagInitNoError() 26 public function testWallabagInitNoError()
27 { 27 {
28 $conf = new ConfigManager(''); 28 $conf = new ConfigManager('');
29 $conf->set('plugins.WALLABAG_URL', 'value'); 29 $conf->set('plugins.WALLABAG_URL', 'value');
@@ -34,7 +34,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
34 /** 34 /**
35 * Test wallabag init with errors. 35 * Test wallabag init with errors.
36 */ 36 */
37 function testWallabagInitError() 37 public function testWallabagInitError()
38 { 38 {
39 $conf = new ConfigManager(''); 39 $conf = new ConfigManager('');
40 $errors = wallabag_init($conf); 40 $errors = wallabag_init($conf);
@@ -44,7 +44,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
44 /** 44 /**
45 * Test render_linklist hook. 45 * Test render_linklist hook.
46 */ 46 */
47 function testWallabagLinklist() 47 public function testWallabagLinklist()
48 { 48 {
49 $conf = new ConfigManager(''); 49 $conf = new ConfigManager('');
50 $conf->set('plugins.WALLABAG_URL', 'value'); 50 $conf->set('plugins.WALLABAG_URL', 'value');
diff --git a/tests/plugins/WallabagInstanceTest.php b/tests/plugins/WallabagInstanceTest.php
index 7c14c1df..2c466871 100644
--- a/tests/plugins/WallabagInstanceTest.php
+++ b/tests/plugins/WallabagInstanceTest.php
@@ -15,7 +15,7 @@ class WallabagInstanceTest extends PHPUnit_Framework_TestCase
15 /** 15 /**
16 * Reset plugin path 16 * Reset plugin path
17 */ 17 */
18 function setUp() 18 public function setUp()
19 { 19 {
20 $this->instance = 'http://some.url'; 20 $this->instance = 'http://some.url';
21 } 21 }
@@ -23,7 +23,7 @@ class WallabagInstanceTest extends PHPUnit_Framework_TestCase
23 /** 23 /**
24 * Test WallabagInstance with API V1. 24 * Test WallabagInstance with API V1.
25 */ 25 */
26 function testWallabagInstanceV1() 26 public function testWallabagInstanceV1()
27 { 27 {
28 $instance = new WallabagInstance($this->instance, 1); 28 $instance = new WallabagInstance($this->instance, 1);
29 $expected = $this->instance . '/?plainurl='; 29 $expected = $this->instance . '/?plainurl=';
@@ -34,7 +34,7 @@ class WallabagInstanceTest extends PHPUnit_Framework_TestCase
34 /** 34 /**
35 * Test WallabagInstance with API V2. 35 * Test WallabagInstance with API V2.
36 */ 36 */
37 function testWallabagInstanceV2() 37 public function testWallabagInstanceV2()
38 { 38 {
39 $instance = new WallabagInstance($this->instance, 2); 39 $instance = new WallabagInstance($this->instance, 2);
40 $expected = $this->instance . '/bookmarklet?url='; 40 $expected = $this->instance . '/bookmarklet?url=';
@@ -45,7 +45,7 @@ class WallabagInstanceTest extends PHPUnit_Framework_TestCase
45 /** 45 /**
46 * Test WallabagInstance with an invalid API version. 46 * Test WallabagInstance with an invalid API version.
47 */ 47 */
48 function testWallabagInstanceInvalidVersion() 48 public function testWallabagInstanceInvalidVersion()
49 { 49 {
50 $instance = new WallabagInstance($this->instance, false); 50 $instance = new WallabagInstance($this->instance, false);
51 $expected = $this->instance . '/?plainurl='; 51 $expected = $this->instance . '/?plainurl=';