This repository has been archived by the owner on Mar 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a241016
commit a35b4c1
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
tests/Humbug/Test/SelfUpdate/UpdaterManifestStrategyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Humbug\Test\SelfUpdate; | ||
|
||
use Humbug\SelfUpdate\Updater; | ||
use Humbug\SelfUpdate\Strategy\ManifestStrategy; | ||
|
||
class UpdaterManifestStrategyTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
private $files; | ||
|
||
/** @var Updater */ | ||
private $updater; | ||
|
||
private $manifestFile; | ||
|
||
private $tmp; | ||
|
||
public function setup() | ||
{ | ||
$this->tmp = sys_get_temp_dir(); | ||
$this->files = __DIR__ . '/_files'; | ||
$this->updater = new Updater($this->files . '/test.phar', false); | ||
$this->manifestFile = $this->files . '/manifest.json'; | ||
} | ||
|
||
public function testGetLocalVersion() | ||
{ | ||
$strategy = new ManifestStrategy('1.0.0', $this->manifestFile); | ||
$this->assertEquals('1.0.0', $strategy->getCurrentLocalVersion($this->updater)); | ||
} | ||
|
||
public function testSuggestMostRecentStable() | ||
{ | ||
$strategy = new ManifestStrategy('1.0.0', $this->manifestFile); | ||
$this->assertEquals('1.2.0', $strategy->getCurrentRemoteVersion($this->updater)); | ||
} | ||
|
||
public function testSuggestNewestUnstable() | ||
{ | ||
$strategy = new ManifestStrategy('1.0.0', $this->manifestFile, false, true); | ||
$this->assertEquals('1.3.0-beta', $strategy->getCurrentRemoteVersion($this->updater)); | ||
} | ||
|
||
public function testSuggestNewestStableFromUnstable() | ||
{ | ||
$strategy = new ManifestStrategy('1.0.0-beta', $this->manifestFile); | ||
$this->assertEquals('1.2.0', $strategy->getCurrentRemoteVersion($this->updater)); | ||
} | ||
|
||
public function testSuggestNewestUnstableFromUnstable() | ||
{ | ||
$strategy = new ManifestStrategy('1.2.9-beta', $this->manifestFile); | ||
$this->assertEquals('1.3.0-beta', $strategy->getCurrentRemoteVersion($this->updater)); | ||
} | ||
|
||
public function testUpdate() | ||
{ | ||
copy($this->files . '/test.phar', $this->tmp . '/test.phar'); | ||
$updater = new Updater($this->tmp . '/test.phar', false); | ||
$strategy = new ManifestStrategy('1.0.0', $this->manifestFile); | ||
$updater->setStrategyObject($strategy); | ||
$updater->setBackupPath($this->tmp . '/backup.phar'); | ||
$cwd = getcwd(); | ||
chdir(__DIR__); | ||
$updater->update(); | ||
chdir($cwd); | ||
} | ||
|
||
public function teardown() | ||
{ | ||
@unlink($this->tmp . '/test.phar'); | ||
@unlink($this->tmp . '/backup.phar'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "2.0.0" | ||
}, | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "2.0.0-beta" | ||
}, | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "1.3.0-beta" | ||
}, | ||
{ | ||
"sha1": "0bc24f886bc0c7563187167b334e56cfb8e1151a", | ||
"url": "_files/build/nosig.phar", | ||
"version": "1.2.0" | ||
}, | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "1.1.0" | ||
}, | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "1.0.0" | ||
}, | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "1.0.0-beta" | ||
}, | ||
{ | ||
"sha1": "", | ||
"url": "", | ||
"version": "0.9.0" | ||
} | ||
] |