diff --git a/.travis.yml b/.travis.yml
index bcaf682ce..d1c701729 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,6 +3,7 @@ php:
- 5.6
- 5.5
- 5.4
+ - 5.3
install:
- composer self-update
- composer install
diff --git a/README.md b/README.md
index 15d4379af..b3dbaf5fa 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ Password: `demo`
## Installing
-Shaarli requires php 5.4. `php-gd` is optional and provides thumbnail resizing.
+Shaarli requires PHP 5.3. `php-gd` is optional and provides thumbnail resizing.
* Download the latest stable release from https://github.com/shaarli/Shaarli/releases
* Unpack the archive in a directory on your web server
diff --git a/application/Config.php b/application/Config.php
index 0b01b5246..ec799d7f7 100755
--- a/application/Config.php
+++ b/application/Config.php
@@ -19,10 +19,10 @@
function writeConfig($config, $isLoggedIn)
{
// These fields are required in configuration.
- $MANDATORY_FIELDS = [
+ $MANDATORY_FIELDS = array(
'login', 'hash', 'salt', 'timezone', 'title', 'titleLink',
'redirector', 'disablesessionprotection', 'privateLinkByDefault'
- ];
+ );
if (!isset($config['config']['CONFIG_FILE'])) {
throw new MissingFieldConfigException('CONFIG_FILE');
@@ -126,4 +126,4 @@ public function __construct()
{
$this->message = 'You are not authorized to alter config.';
}
-}
\ No newline at end of file
+}
diff --git a/application/TimeZone.php b/application/TimeZone.php
new file mode 100644
index 000000000..ccbef918b
--- /dev/null
+++ b/application/TimeZone.php
@@ -0,0 +1,110 @@
+'.$city.'';
+ }
+ }
+
+ $continents_html = '';
+ $continents = array_keys($continents);
+
+ foreach ($continents as $continent) {
+ $continents_html .= '';
- }
- }
- $continents_html = '';
- $continents = array_keys($continents);
- foreach($continents as $continent)
- $continents_html.='';
- $cities_html = $cities[$pcontinent];
- $timezone_form = "Continent: ";
- $timezone_form .= " City:
";
- $timezone_js = "" ;
- return array($timezone_form,$timezone_js);
- }
- return array('','');
-}
-
-// Tells if a timezone is valid or not.
-// If not valid, returns false.
-// If system does not support timezone list, returns false.
-function isTZvalid($continent,$city)
-{
- $tz = $continent.'/'.$city;
- if (function_exists('timezone_identifiers_list')) // because of old PHP version (5.1) which can be found on free.fr
- {
- if (in_array($tz, timezone_identifiers_list())) // it's a valid timezone?
- return true;
- }
- return false;
-}
if (!function_exists('json_encode')) {
function json_encode($data) {
switch ($type = gettype($data)) {
diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php
index 4279c57e5..a239d8b7d 100755
--- a/tests/ConfigTest.php
+++ b/tests/ConfigTest.php
@@ -18,7 +18,7 @@ class ConfigTest extends PHPUnit_Framework_TestCase
*/
public function setUp()
{
- self::$_configFields = [
+ self::$_configFields = array(
'login' => 'login',
'hash' => 'hash',
'salt' => 'salt',
@@ -28,13 +28,13 @@ public function setUp()
'redirector' => '',
'disablesessionprotection' => false,
'privateLinkByDefault' => false,
- 'config' => [
+ 'config' => array(
'CONFIG_FILE' => 'tests/config.php',
'DATADIR' => 'tests',
'config1' => 'config1data',
'config2' => 'config2data',
- ]
- ];
+ )
+ );
}
/**
@@ -174,4 +174,4 @@ public function testMergeDeprecatedConfigNoFile()
include self::$_configFields['config']['CONFIG_FILE'];
$this->assertEquals(self::$_configFields['login'], $GLOBALS['login']);
}
-}
\ No newline at end of file
+}
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index d34ea4f56..504c81901 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -228,12 +228,12 @@ public function testCountHiddenPublic()
public function testDays()
{
$this->assertEquals(
- ['20121206', '20130614', '20150310'],
+ array('20121206', '20130614', '20150310'),
self::$publicLinkDB->days()
);
$this->assertEquals(
- ['20121206', '20130614', '20141125', '20150310'],
+ array('20121206', '20130614', '20141125', '20150310'),
self::$privateLinkDB->days()
);
}
@@ -269,7 +269,7 @@ public function testGetUnknownLinkFromURL()
public function testAllTags()
{
$this->assertEquals(
- [
+ array(
'web' => 3,
'cartoon' => 2,
'gnu' => 2,
@@ -279,12 +279,12 @@ public function testAllTags()
'software' => 1,
'stallman' => 1,
'free' => 1
- ],
+ ),
self::$publicLinkDB->allTags()
);
$this->assertEquals(
- [
+ array(
'web' => 4,
'cartoon' => 3,
'gnu' => 2,
@@ -298,7 +298,7 @@ public function testAllTags()
'w3c' => 1,
'css' => 1,
'Mercurial' => 1
- ],
+ ),
self::$privateLinkDB->allTags()
);
}
diff --git a/tests/TimeZoneTest.php b/tests/TimeZoneTest.php
new file mode 100644
index 000000000..f3de39139
--- /dev/null
+++ b/tests/TimeZoneTest.php
@@ -0,0 +1,83 @@
+assertStringStartsWith('Continent:
', $generated[0]);
+
+ // Javascript handler
+ $this->assertStringStartsWith('', $generated[1]);
+ }
+
+ /**
+ * Generate a timezone selection form, with a preselected timezone
+ */
+ public function testGenerateTimeZoneFormPreselected()
+ {
+ $generated = generateTimeZoneForm('Antarctica/Syowa');
+
+ // HTML form
+ $this->assertStringStartsWith('Continent:
', $generated[0]);
+
+
+ // Javascript handler
+ $this->assertStringStartsWith('', $generated[1]);
+ }
+
+ /**
+ * Check valid timezones
+ */
+ public function testValidTimeZone()
+ {
+ $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
+ $this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
+ $this->assertTrue(isTimeZoneValid('UTC', 'UTC'));
+ }
+
+ /**
+ * Check invalid timezones
+ */
+ public function testInvalidTimeZone()
+ {
+ $this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
+ $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
+ $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
+ }
+}
+?>
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php
index 8355c7f81..28e15f5a6 100644
--- a/tests/UtilsTest.php
+++ b/tests/UtilsTest.php
@@ -109,7 +109,7 @@ public function testGenerateLocation() {
*/
public function testGenerateLocationLoop() {
$ref = 'http://localhost/?test';
- $this->assertEquals('?', generateLocation($ref, 'localhost', ['test']));
+ $this->assertEquals('?', generateLocation($ref, 'localhost', array('test')));
}
/**
@@ -119,4 +119,36 @@ public function testGenerateLocationOut() {
$ref = 'http://somewebsite.com/?test';
$this->assertEquals('?', generateLocation($ref, 'localhost'));
}
+
+ /**
+ * Check supported PHP versions
+ */
+ public function testCheckSupportedPHPVersion()
+ {
+ $minVersion = '5.3';
+ checkPHPVersion($minVersion, '5.4.32');
+ checkPHPVersion($minVersion, '5.5');
+ checkPHPVersion($minVersion, '5.6.10');
+ }
+
+ /**
+ * Check a unsupported PHP version
+ * @expectedException Exception
+ * @expectedExceptionMessageRegExp /Your PHP version is obsolete/
+ */
+ public function testCheckSupportedPHPVersion51()
+ {
+ checkPHPVersion('5.3', '5.1.0');
+ }
+
+ /**
+ * Check another unsupported PHP version
+ * @expectedException Exception
+ * @expectedExceptionMessageRegExp /Your PHP version is obsolete/
+ */
+ public function testCheckSupportedPHPVersion52()
+ {
+ checkPHPVersion('5.3', '5.2');
+ }
}
+?>