1
0
Fork 0

Fix tests

pull/1745/head
Jordi Boggiano 2013-03-28 20:42:25 +01:00
parent 99eb2252f4
commit bf307de1d6
3 changed files with 10 additions and 52 deletions

View File

@ -19,7 +19,7 @@ Requirements from the composer file are not installed if the lock file is presen
--LOCK--
{
"packages": [
{ "package": "required", "version": "1.0.0" }
{ "name": "required", "version": "1.0.0" }
],
"packages-dev": null,
"aliases": [],

View File

@ -24,9 +24,9 @@ Limited update takes rules from lock if available, and not from the installed re
--LOCK--
{
"packages": [
{ "package": "old/installed", "version": "1.0.0" },
{ "package": "toupdate/installed", "version": "1.0.0" },
{ "package": "toupdate/notinstalled", "version": "1.0.0" }
{ "name": "old/installed", "version": "1.0.0" },
{ "name": "toupdate/installed", "version": "1.0.0" },
{ "name": "toupdate/notinstalled", "version": "1.0.0" }
],
"packages-dev": null,
"aliases": [],

View File

@ -13,6 +13,7 @@
namespace Composer\Test\Package;
use Composer\Package\Locker;
use Composer\Package\CompletePackage;
class LockerTest extends \PHPUnit_Framework_TestCase
{
@ -68,57 +69,14 @@ class LockerTest extends \PHPUnit_Framework_TestCase
->method('read')
->will($this->returnValue(array(
'packages' => array(
array('package' => 'pkg1', 'version' => '1.0.0-beta'),
array('package' => 'pkg2', 'version' => '0.1.10')
array('name' => 'pkg1', 'version' => '1.0.0-beta'),
array('name' => 'pkg2', 'version' => '0.1.10')
)
)));
$package1 = $this->createPackageMock();
$package2 = $this->createPackageMock();
$repo->getLocalRepository()
->expects($this->exactly(2))
->method('findPackage')
->with($this->logicalOr('pkg1', 'pkg2'), $this->logicalOr('1.0.0-beta', '0.1.10'))
->will($this->onConsecutiveCalls($package1, $package2));
$this->assertEquals(array($package1, $package2), $locker->getLockedRepository()->getPackages());
}
public function testGetPackagesWithoutRepo()
{
$json = $this->createJsonFileMock();
$repo = $this->createRepositoryManagerMock();
$inst = $this->createInstallationManagerMock();
$locker = new Locker($json, $repo, $inst, 'md5');
$json
->expects($this->once())
->method('exists')
->will($this->returnValue(true));
$json
->expects($this->once())
->method('read')
->will($this->returnValue(array(
'packages' => array(
array('package' => 'pkg1', 'version' => '1.0.0-beta'),
array('package' => 'pkg2', 'version' => '0.1.10')
)
)));
$package1 = $this->createPackageMock();
$package2 = $this->createPackageMock();
$repo->getLocalRepository()
->expects($this->exactly(2))
->method('findPackage')
->with($this->logicalOr('pkg1', 'pkg2'), $this->logicalOr('1.0.0-beta', '0.1.10'))
->will($this->onConsecutiveCalls($package1, null));
$this->setExpectedException('LogicException');
$locker->getLockedRepository();
$repo = $locker->getLockedRepository();
$this->assertNotNull($repo->findPackage('pkg1', '1.0.0-beta'));
$this->assertNotNull($repo->findPackage('pkg2', '0.1.10'));
}
public function testSetLockData()