From f53c65956e6bb54f7a8eeb795789188378110c58 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 28 May 2015 14:07:27 +0200 Subject: [PATCH 1/2] Added support for PHP 5.3.3 --- .travis.yml | 2 + composer.json | 2 +- src/VersionParser.php | 8 ++-- .../SelfUpdate/UpdaterGithubStrategyTest.php | 24 ++++++------ .../Test/SelfUpdate/VersionParserTest.php | 38 +++++++++---------- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 271b705..6211cde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ php: - 5.6 - 5.5 - 5.4 + - 5.3 + - 5.3.3 - hhvm - hhvm-nightly diff --git a/composer.json b/composer.json index 8876e39..67aaf27 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=5.4", + "php": ">=5.3.3", "padraic/humbug_get_contents": "^1.0", "symfony/finder": "~2.2" }, diff --git a/src/VersionParser.php b/src/VersionParser.php index 1267c2d..69e2fa4 100644 --- a/src/VersionParser.php +++ b/src/VersionParser.php @@ -28,7 +28,7 @@ class VersionParser /** * @param array $versions */ - public function __construct(array $versions = []) + public function __construct(array $versions = array()) { $this->versions = $versions; } @@ -114,7 +114,7 @@ public function isDevelopment($version) private function selectRecentStable() { - $candidates = []; + $candidates = array(); foreach ($this->versions as $version) { if (!$this->stable($version)) { continue; @@ -129,7 +129,7 @@ private function selectRecentStable() private function selectRecentUnstable() { - $candidates = []; + $candidates = array(); foreach ($this->versions as $version) { if ($this->stable($version) || $this->development($version)) { continue; @@ -144,7 +144,7 @@ private function selectRecentUnstable() private function selectRecentAll() { - $candidates = []; + $candidates = array(); foreach ($this->versions as $version) { if ($this->development($version)) { continue; diff --git a/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php b/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php index bd2f825..ee8565c 100644 --- a/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php +++ b/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php @@ -141,19 +141,19 @@ private function createTestPharAndKey() ); @mkdir($this->tmp.'/releases/download/1.0.1', 0755, true); copy($this->files.'/build/new.phar', $this->tmp.'/releases/download/1.0.1/new.phar'); - file_put_contents($this->tmp . '/package.json', json_encode([ - 'package' => [ - 'versions' => [ - '1.0.1' => [ - 'source' => [ + file_put_contents($this->tmp . '/package.json', json_encode(array( + 'package' => array( + 'versions' => array( + '1.0.1' => array( + 'source' => array( 'url' => 'file://' . $this->tmp . '.git' - ] - ], - '1.0.0' => [ - ] - ] - ] - ])); + ) + ), + '1.0.0' => array( + ) + ) + ) + ))); } } diff --git a/tests/Humbug/Test/SelfUpdate/VersionParserTest.php b/tests/Humbug/Test/SelfUpdate/VersionParserTest.php index 38d2a4f..66761fa 100644 --- a/tests/Humbug/Test/SelfUpdate/VersionParserTest.php +++ b/tests/Humbug/Test/SelfUpdate/VersionParserTest.php @@ -20,102 +20,102 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase public function testShouldSelectNothingFromUnstablesIfStableRequested() { - $versions = ['1.0.0a', '1.0.0alpha', '1.0.0-dev', 'dev-1.0.0', '1.0.0b', - '1.0.0beta', '1.0.0rc', '1.0.0RC']; + $versions = array('1.0.0a', '1.0.0alpha', '1.0.0-dev', 'dev-1.0.0', '1.0.0b', + '1.0.0beta', '1.0.0rc', '1.0.0RC'); $parser = new VersionParser($versions); $this->assertSame(false, $parser->getMostRecentStable()); } - + public function testShouldSelectMostRecentVersionFromStandardSelection() { - $versions = ['1.0.0', '1.0.1', '1.1.0']; + $versions = array('1.0.0', '1.0.1', '1.1.0'); $parser = new VersionParser($versions); $this->assertSame('1.1.0', $parser->getMostRecentStable()); } public function testShouldSelectMostRecentVersionFromMixedSelection() { - $versions = ['1.0.0', '1.0.1', '1.1.0', '1.2.0a', '1.2.0b', '1.1.0rc']; + $versions = array('1.0.0', '1.0.1', '1.1.0', '1.2.0a', '1.2.0b', '1.1.0rc'); $parser = new VersionParser($versions); $this->assertSame('1.1.0', $parser->getMostRecentStable()); } public function testShouldSelectMostRecentVersionFromPrefixedSelection() { - $versions = ['v1.0.0', 'v1.0.1', 'v1.1.0']; + $versions = array('v1.0.0', 'v1.0.1', 'v1.1.0'); $parser = new VersionParser($versions); $this->assertSame('v1.1.0', $parser->getMostRecentStable()); } public function testShouldSelectMostRecentVersionFromPartlyPrefixedSelection() { - $versions = ['v1.0.0', 'v1.0.1', '1.1.0']; + $versions = array('v1.0.0', 'v1.0.1', '1.1.0'); $parser = new VersionParser($versions); $this->assertSame('1.1.0', $parser->getMostRecentStable()); } public function testShouldSelectMostRecentVersionFromPatchLevels() { - $versions = ['1.0.0', '1.0.0-pl2', '1.0.0-pl3', '1.0.0-pl1']; + $versions = array('1.0.0', '1.0.0-pl2', '1.0.0-pl3', '1.0.0-pl1'); $parser = new VersionParser($versions); $this->assertSame('1.0.0-pl3', $parser->getMostRecentStable()); } public function testShouldSelectMostRecentVersionFromPatchLevels2() { - $versions = ['1.0.0', '1.0.0pl2', '1.0.0pl3', '1.0.0pl1']; + $versions = array('1.0.0', '1.0.0pl2', '1.0.0pl3', '1.0.0pl1'); $parser = new VersionParser($versions); $this->assertSame('1.0.0pl3', $parser->getMostRecentStable()); } // Unstable - + public function testShouldSelectNothingFromUnstablesIfUnstableRequested() { - $versions = ['1.0.0', '1.0.1', '1.1.0']; + $versions = array('1.0.0', '1.0.1', '1.1.0'); $parser = new VersionParser($versions); $this->assertSame(false, $parser->getMostRecentUnstable()); } public function testShouldSelectNothingFromStablesOrDevsIfUnstableRequested() { - $versions = ['1.0.0', '1.0.1', '1.1.0-dev', 'dev-1.1.1']; + $versions = array('1.0.0', '1.0.1', '1.1.0-dev', 'dev-1.1.1'); $parser = new VersionParser($versions); $this->assertSame(false, $parser->getMostRecentUnstable()); } public function testShouldSelectMostRecentUnstableVersionFromStandardSelection() { - $versions = ['1.0.0a', '1.0.0alpha', '1.0.0-dev', 'dev-1.0.0', '1.0.0b', - '1.0.0beta', '1.0.0rc', '1.0.0RC']; + $versions = array('1.0.0a', '1.0.0alpha', '1.0.0-dev', 'dev-1.0.0', '1.0.0b', + '1.0.0beta', '1.0.0rc', '1.0.0RC'); $parser = new VersionParser($versions); $this->assertSame('1.0.0rc', $parser->getMostRecentUnstable()); } public function testShouldSelectMostRecentUnstableVersionFromMixedSelection() { - $versions = ['1.0.0', '1.0.1', '1.1.0', '1.2.0a', '1.2.0b', '1.1.0rc']; + $versions = array('1.0.0', '1.0.1', '1.1.0', '1.2.0a', '1.2.0b', '1.1.0rc'); $parser = new VersionParser($versions); $this->assertSame('1.2.0b', $parser->getMostRecentUnstable()); } public function testShouldSelectMostRecentUnstableVersionFromPrefixedSelection() { - $versions = ['v1.0.0b', 'v1.0.1', 'v1.1.0']; + $versions = array('v1.0.0b', 'v1.0.1', 'v1.1.0'); $parser = new VersionParser($versions); $this->assertSame('v1.0.0b', $parser->getMostRecentUnstable()); } public function testShouldSelectMostRecentUnstableVersionFromPartlyPrefixedSelection() { - $versions = ['v1.0.0b', 'v1.0.0a', '1.1.0a']; + $versions = array('v1.0.0b', 'v1.0.0a', '1.1.0a'); $parser = new VersionParser($versions); $this->assertSame('1.1.0a', $parser->getMostRecentUnstable()); } public function testShouldSelectMostRecentUnstableFromVaryingNumeralCounts() { - $versions = ['1.0-dev', '1.0.0-alpha1']; + $versions = array('1.0-dev', '1.0.0-alpha1'); $parser = new VersionParser($versions); $this->assertSame('1.0.0-alpha1', $parser->getMostRecentUnstable()); } @@ -124,7 +124,7 @@ public function testShouldSelectMostRecentUnstableFromVaryingNumeralCounts() public function testShouldSelectMostRecentIgnoringStabilityExceptDevFromPrefixedSelection() { - $versions = ['v1.0.0b', 'v1.0.1', 'v1.1.0a', 'v1.2.0-dev']; + $versions = array('v1.0.0b', 'v1.0.1', 'v1.1.0a', 'v1.2.0-dev'); $parser = new VersionParser($versions); $this->assertSame('v1.1.0a', $parser->getMostRecentAll()); } From 56962eaecf04f9536a7ba72c3972deebd0f2067f Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 28 May 2015 14:38:20 +0200 Subject: [PATCH 2/2] Marked OpenSSL-dependent tests as skipped when the openssl extension is missing (i.e. 5.3.3 on Travis) --- .../Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php | 4 ++++ tests/Humbug/Test/SelfUpdate/UpdaterTest.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php b/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php index ee8565c..930e750 100644 --- a/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php +++ b/tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php @@ -99,6 +99,10 @@ public function testSetStabilityThrowsExceptionOnInvalidStabilityValue() */ public function testUpdatePhar() { + if (!extension_loaded('openssl')) { + $this->markTestSkipped('This test requires the openssl extension to run.'); + } + $this->createTestPharAndKey(); $this->assertEquals('old', $this->getPharOutput($this->tmp . '/old.phar')); diff --git a/tests/Humbug/Test/SelfUpdate/UpdaterTest.php b/tests/Humbug/Test/SelfUpdate/UpdaterTest.php index 1456329..9befebd 100644 --- a/tests/Humbug/Test/SelfUpdate/UpdaterTest.php +++ b/tests/Humbug/Test/SelfUpdate/UpdaterTest.php @@ -132,6 +132,10 @@ public function testThrowsExceptionOnInvalidRemoteVersion() */ public function testUpdatePhar() { + if (!extension_loaded('openssl')) { + $this->markTestSkipped('This test requires the openssl extension to run.'); + } + $this->createTestPharAndKey(); $this->assertEquals('old', $this->getPharOutput($this->tmp . '/old.phar')); @@ -175,6 +179,10 @@ public function testUpdatePharFailsIfCurrentPublicKeyInvalid() */ public function testUpdatePharFailsOnExpectedSignatureMismatch() { + if (!extension_loaded('openssl')) { + $this->markTestSkipped('This test requires the openssl extension to run.'); + } + $this->createTestPharAndKey(); $this->assertEquals('old', $this->getPharOutput($this->tmp . '/old.phar'));