Signed-off-by: VirtualTam <virtualtam@flibidi.net>
26 files changed:
/**
* Toggle HTTP requests, allow overriding the version code
*/
/**
* Toggle HTTP requests, allow overriding the version code
*/
- public static function getVersion($url, $timeout=0)
+ public static function getVersion($url, $timeout = 0)
{
return self::$VERSION_CODE;
}
{
return self::$VERSION_CODE;
}
'0.5.4',
ApplicationUtils::getVersion(
'https://raw.githubusercontent.com/shaarli/Shaarli/'
'0.5.4',
ApplicationUtils::getVersion(
'https://raw.githubusercontent.com/shaarli/Shaarli/'
- .'v0.5.4/shaarli_version.php',
+ .'v0.5.4/shaarli_version.php',
self::$versionPattern,
ApplicationUtils::getVersion(
'https://raw.githubusercontent.com/shaarli/Shaarli/'
self::$versionPattern,
ApplicationUtils::getVersion(
'https://raw.githubusercontent.com/shaarli/Shaarli/'
- .'latest/shaarli_version.php',
+ .'latest/shaarli_version.php',
invalidateCaches(self::$testCacheDir);
foreach (self::$pages as $page) {
$this->assertFileNotExists(self::$testCacheDir.'/'.$page.'.cache');
invalidateCaches(self::$testCacheDir);
foreach (self::$pages as $page) {
$this->assertFileNotExists(self::$testCacheDir.'/'.$page.'.cache');
$this->assertArrayNotHasKey('tags', $_SESSION);
}
$this->assertArrayNotHasKey('tags', $_SESSION);
}
/**
* Unitary tests for getIpAddressFromProxy()
*/
/**
* Unitary tests for getIpAddressFromProxy()
*/
-class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase {
+class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase
+{
public function testLinkRealUrlWithoutRedirector()
{
$db = new LinkDB(self::$testDatastore, false, false);
public function testLinkRealUrlWithoutRedirector()
{
$db = new LinkDB(self::$testDatastore, false, false);
- foreach($db as $link) {
+ foreach ($db as $link) {
$this->assertEquals($link['url'], $link['real_url']);
}
}
$this->assertEquals($link['url'], $link['real_url']);
}
}
{
$redirector = 'http://redirector.to?';
$db = new LinkDB(self::$testDatastore, false, false, $redirector);
{
$redirector = 'http://redirector.to?';
$db = new LinkDB(self::$testDatastore, false, false, $redirector);
- foreach($db as $link) {
+ foreach ($db as $link) {
$this->assertStringStartsWith($redirector, $link['real_url']);
$this->assertNotFalse(strpos($link['real_url'], urlencode('://')));
}
$db = new LinkDB(self::$testDatastore, false, false, $redirector, false);
$this->assertStringStartsWith($redirector, $link['real_url']);
$this->assertNotFalse(strpos($link['real_url'], urlencode('://')));
}
$db = new LinkDB(self::$testDatastore, false, false, $redirector, false);
- foreach($db as $link) {
+ foreach ($db as $link) {
$this->assertStringStartsWith($redirector, $link['real_url']);
$this->assertFalse(strpos($link['real_url'], urlencode('://')));
}
$this->assertStringStartsWith($redirector, $link['real_url']);
$this->assertFalse(strpos($link['real_url'], urlencode('://')));
}
$this->assertEquals(
3,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"'))
$this->assertEquals(
3,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"'))
Router::$PAGE_CHANGEPASSWORD,
Router::findPage('do=changepasswd&stuff', array(), true)
);
Router::$PAGE_CHANGEPASSWORD,
Router::findPage('do=changepasswd&stuff', array(), true)
);
ini_set('error_log', $oldlog);
}
ini_set('error_log', $oldlog);
}
- protected function rrmdirContent($dir) {
+ protected function rrmdirContent($dir)
+ {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
- if (is_dir($dir."/".$object))
+ if (is_dir($dir."/".$object)) {
$this->rrmdirContent($dir."/".$object);
$this->rrmdirContent($dir."/".$object);
unlink($dir."/".$object);
unlink($dir."/".$object);
*
* @return bool true.
*/
*
* @return bool true.
*/
- private final function updateMethodDummy1()
+ final private function updateMethodDummy1()
*
* @return bool true.
*/
*
* @return bool true.
*/
- private final function updateMethodDummy2()
+ final private function updateMethodDummy2()
*
* @return bool true.
*/
*
* @return bool true.
*/
- private final function updateMethodDummy3()
+ final private function updateMethodDummy3()
*
* @throws Exception error.
*/
*
* @throws Exception error.
*/
- private final function updateMethodException()
+ final private function updateMethodException()
{
throw new Exception('whatever');
}
{
throw new Exception('whatever');
}
$this->assertEquals('git', get_url_scheme('git://domain.tld/push?pull=clone#checkout'));
}
}
$this->assertEquals('git', get_url_scheme('git://domain.tld/push?pull=clone#checkout'));
}
}
$this->assertEquals($ref, unparse_url(parse_url($ref)));
}
}
$this->assertEquals($ref, unparse_url(parse_url($ref)));
}
}
- private function assertUrlIsCleaned($query='', $fragment='')
+ private function assertUrlIsCleaned($query = '', $fragment = '')
{
$url = new Url(self::$baseUrl.$query.$fragment);
$url->cleanup();
{
$url = new Url(self::$baseUrl.$query.$fragment);
$url->cleanup();
'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept')
);
$this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup());
'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept')
);
$this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup());
}
/**
* Test default http scheme.
*/
}
/**
* Test default http scheme.
*/
- public function testDefaultScheme() {
+ public function testDefaultScheme()
+ {
$url = new Url(self::$baseUrl);
$this->assertEquals('http', $url->getScheme());
$url = new Url('domain.tld');
$url = new Url(self::$baseUrl);
$this->assertEquals('http', $url->getScheme());
$url = new Url('domain.tld');
/**
* Test generate location with valid data.
*/
/**
* Test generate location with valid data.
*/
- public function testGenerateLocation() {
+ public function testGenerateLocation()
+ {
$ref = 'http://localhost/?test';
$this->assertEquals($ref, generateLocation($ref, 'localhost'));
$ref = 'http://localhost:8080/?test';
$ref = 'http://localhost/?test';
$this->assertEquals($ref, generateLocation($ref, 'localhost'));
$ref = 'http://localhost:8080/?test';
/**
* Test generate location - anti loop.
*/
/**
* Test generate location - anti loop.
*/
- public function testGenerateLocationLoop() {
+ public function testGenerateLocationLoop()
+ {
$ref = 'http://localhost/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost', array('test')));
}
$ref = 'http://localhost/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost', array('test')));
}
/**
* Test generate location - from other domain.
*/
/**
* Test generate location - from other domain.
*/
- public function testGenerateLocationOut() {
+ public function testGenerateLocationOut()
+ {
$ref = 'http://somewebsite.com/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost'));
}
$ref = 'http://somewebsite.com/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost'));
}
/**
* Class ApiUtilsTest
*/
/**
* Class ApiUtilsTest
*/
$payload = Base64Url::encode('{
"iat": '. time() .'
}');
$payload = Base64Url::encode('{
"iat": '. time() .'
}');
- $signature = Base64Url::encode(hash_hmac('sha512', $header .'.'. $payload , $secret, true));
+ $signature = Base64Url::encode(hash_hmac('sha512', $header .'.'. $payload, $secret, true));
return $header .'.'. $payload .'.'. $signature;
}
return $header .'.'. $payload .'.'. $signature;
}
namespace Shaarli\Api\Controllers;
namespace Shaarli\Api\Controllers;
use Shaarli\Config\ConfigManager;
use Slim\Container;
use Slim\Http\Environment;
use Shaarli\Config\ConfigManager;
use Slim\Container;
use Slim\Http\Environment;
* Test REST API controller Info.
* Test REST API controller Info.
* @package Api\Controllers
*/
class InfoTest extends \PHPUnit_Framework_TestCase
* @package Api\Controllers
*/
class InfoTest extends \PHPUnit_Framework_TestCase
namespace Shaarli\Api\Controllers;
namespace Shaarli\Api\Controllers;
use PHPUnit\Framework\TestCase;
use Shaarli\Config\ConfigManager;
use Slim\Container;
use PHPUnit\Framework\TestCase;
use Shaarli\Config\ConfigManager;
use Slim\Container;
namespace Shaarli\Api\Controllers;
namespace Shaarli\Api\Controllers;
use Shaarli\Config\ConfigManager;
use Slim\Container;
use Slim\Http\Environment;
use Shaarli\Config\ConfigManager;
use Slim\Container;
use Slim\Http\Environment;
namespace Shaarli\Api\Controllers;
namespace Shaarli\Api\Controllers;
use Shaarli\Api\Exceptions\ApiBadParametersException;
use Shaarli\Config\ConfigManager;
use Slim\Container;
use Shaarli\Api\Exceptions\ApiBadParametersException;
use Shaarli\Config\ConfigManager;
use Slim\Container;
public function testDateFormatNoTime()
{
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
public function testDateFormatNoTime()
{
$date = DateTime::createFromFormat('Ymd_His', '20170101_101112');
- $this->assertRegExp('/1\. Januar 2017/', format_date($date, false,true));
+ $this->assertRegExp('/1\. Januar 2017/', format_date($date, false, true));
use Shaarli\Config\ConfigManager;
/**
use Shaarli\Config\ConfigManager;
/**
/**
* Reset plugin path
*/
/**
* Reset plugin path
*/
- public function setUp() {
+ public function setUp()
+ {
PluginManager::$PLUGINS_PATH = 'plugins';
}
PluginManager::$PLUGINS_PATH = 'plugins';
}
use \Shaarli\Security\SessionManager;
use \PHPUnit\Framework\TestCase;
use \Shaarli\Security\SessionManager;
use \PHPUnit\Framework\TestCase;
/**
* Test coverage for SessionManager
*/
/**
* Test coverage for SessionManager
*/
$tags,
$updated = '',
$shorturl = '',
$tags,
$updated = '',
$shorturl = '',
$link = array(
'id' => $id,
'title' => $title,
$link = array(
'id' => $id,
'title' => $title,
$order = $order === 'ASC' ? -1 : 1;
// Reorder array by dates.
$order = $order === 'ASC' ? -1 : 1;
// Reorder array by dates.
- usort($this->_links, function($a, $b) use ($order) {
+ usort($this->_links, function ($a, $b) use ($order) {
if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) {
return $a['sticky'] ? -1 : 1;
}
if (isset($a['sticky']) && isset($b['sticky']) && $a['sticky'] !== $b['sticky']) {
return $a['sticky'] ? -1 : 1;
}
$GLOBALS['login'] = 'root';
$GLOBALS['hash'] = 'hash';
$GLOBALS['salt'] = 'salt';
$GLOBALS['login'] = 'root';
$GLOBALS['hash'] = 'hash';
$GLOBALS['salt'] = 'salt';