Add tests
parent
462ebdf752
commit
56e43e4397
|
@ -50,6 +50,11 @@ class Locker
|
|||
return $this->lockFile->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the lock file is still up to date with the current hash
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isFresh()
|
||||
{
|
||||
$lock = $this->lockFile->read();
|
||||
|
|
|
@ -174,6 +174,36 @@ class LockerTest extends \PHPUnit_Framework_TestCase
|
|||
$locker->lockPackages(array($package1));
|
||||
}
|
||||
|
||||
public function testIsFresh()
|
||||
{
|
||||
$json = $this->createJsonFileMock();
|
||||
$repo = $this->createRepositoryManagerMock();
|
||||
|
||||
$locker = new Locker($json, $repo, 'md5');
|
||||
|
||||
$json
|
||||
->expects($this->once())
|
||||
->method('read')
|
||||
->will($this->returnValue(array('hash' => 'md5')));
|
||||
|
||||
$this->assertTrue($locker->isFresh());
|
||||
}
|
||||
|
||||
public function testIsFreshFalse()
|
||||
{
|
||||
$json = $this->createJsonFileMock();
|
||||
$repo = $this->createRepositoryManagerMock();
|
||||
|
||||
$locker = new Locker($json, $repo, 'md5');
|
||||
|
||||
$json
|
||||
->expects($this->once())
|
||||
->method('read')
|
||||
->will($this->returnValue(array('hash' => 'oldmd5')));
|
||||
|
||||
$this->assertFalse($locker->isFresh());
|
||||
}
|
||||
|
||||
private function createJsonFileMock()
|
||||
{
|
||||
return $this->getMockBuilder('Composer\Json\JsonFile')
|
||||
|
|
Loading…
Reference in New Issue