소스 검색

Update locker tests

Jordi Boggiano 8 년 전
부모
커밋
6ec8b2bfd6
1개의 변경된 파일17개의 추가작업 그리고 2개의 파일을 삭제
  1. 17 2
      tests/Composer/Test/Package/LockerTest.php

+ 17 - 2
tests/Composer/Test/Package/LockerTest.php

@@ -118,7 +118,6 @@ class LockerTest extends \PHPUnit_Framework_TestCase
             ->method('getVersion')
             ->will($this->returnValue('0.1.10.0'));
 
-        $hash = md5($jsonContent);
         $contentHash = md5(trim($jsonContent));
 
         $json
@@ -128,7 +127,6 @@ class LockerTest extends \PHPUnit_Framework_TestCase
                 '_readme' => array('This file locks the dependencies of your project to a known state',
                                    'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file',
                                    'This file is @gener'.'ated automatically', ),
-                'hash' => $hash,
                 'content-hash' => $contentHash,
                 'packages' => array(
                     array('name' => 'pkg1', 'version' => '1.0.0-beta'),
@@ -217,6 +215,23 @@ class LockerTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($locker->isFresh());
     }
 
+    public function testIsFreshWithContentHashAndNoHash()
+    {
+        $json = $this->createJsonFileMock();
+        $repo = $this->createRepositoryManagerMock();
+        $inst = $this->createInstallationManagerMock();
+
+        $jsonContent = $this->getJsonContent();
+        $locker = new Locker(new NullIO, $json, $repo, $inst, $jsonContent);
+
+        $json
+            ->expects($this->once())
+            ->method('read')
+            ->will($this->returnValue(array('content-hash' => md5($jsonContent))));
+
+        $this->assertTrue($locker->isFresh());
+    }
+
     public function testIsFreshFalseWithContentHash()
     {
         $json = $this->createJsonFileMock();