Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from webmozart/5.3-support
Browse files Browse the repository at this point in the history
Added support for PHP 5.3.3
  • Loading branch information
padraic committed May 28, 2015
2 parents 45f51e1 + 56962ea commit 0ee989e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ php:
- 5.6
- 5.5
- 5.4
- 5.3
- 5.3.3
- hhvm
- hhvm-nightly

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"php": ">=5.4",
"php": ">=5.3.3",
"padraic/humbug_get_contents": "^1.0",
"symfony/finder": "~2.2"
},
Expand Down
8 changes: 4 additions & 4 deletions src/VersionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class VersionParser
/**
* @param array $versions
*/
public function __construct(array $versions = [])
public function __construct(array $versions = array())
{
$this->versions = $versions;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public function isDevelopment($version)

private function selectRecentStable()
{
$candidates = [];
$candidates = array();
foreach ($this->versions as $version) {
if (!$this->stable($version)) {
continue;
Expand All @@ -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;
Expand All @@ -144,7 +144,7 @@ private function selectRecentUnstable()

private function selectRecentAll()
{
$candidates = [];
$candidates = array();
foreach ($this->versions as $version) {
if ($this->development($version)) {
continue;
Expand Down
28 changes: 16 additions & 12 deletions tests/Humbug/Test/SelfUpdate/UpdaterGithubStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -141,19 +145,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(
)
)
)
)));
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Humbug/Test/SelfUpdate/UpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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'));

Expand Down
38 changes: 19 additions & 19 deletions tests/Humbug/Test/SelfUpdate/VersionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down

0 comments on commit 0ee989e

Please sign in to comment.