@@ -53,21 +53,21 @@ public function testSameBaseAndTarget()
5353 */
5454 public function testGitUsage (array $ expected , $ dev , $ withPlatform )
5555 {
56- $ gitDir = __DIR__ .'/test-git ' ;
5756 $ diff = new PackageDiff ();
58- @mkdir ($ gitDir );
59- chdir ($ gitDir );
60- exec ('git init ' );
61- exec ('git config user.name test ' );
62- exec ('git config user.email test@example.com ' );
63- file_put_contents ($ gitDir .'/composer.lock ' , file_get_contents (__DIR__ .'/fixtures/base/composer.lock ' ));
64- exec ('git add composer.lock && git commit -m "init" ' );
65- file_put_contents ($ gitDir .'/composer.lock ' , file_get_contents (__DIR__ .'/fixtures/target/composer.lock ' ));
66- $ operations = $ diff ->getPackageDiff ('HEAD:composer.lock ' , 'composer.lock ' , $ dev , $ withPlatform );
57+ $ this ->prepareGit ();
58+ $ operations = $ diff ->getPackageDiff ('HEAD ' , '' , $ dev , $ withPlatform );
6759
6860 $ this ->assertSame ($ expected , array_map (array ($ this , 'operationToString ' ), $ operations ));
6961 }
7062
63+ public function testInvalidGitRef ()
64+ {
65+ $ diff = new PackageDiff ();
66+ $ this ->prepareGit ();
67+ $ this ->expectException ('RuntimeException ' );
68+ $ diff ->getPackageDiff ('invalid-ref ' , '' );
69+ }
70+
7171 public function operationsProvider ()
7272 {
7373 return array (
@@ -123,6 +123,19 @@ public function operationsProvider()
123123 );
124124 }
125125
126+ private function prepareGit ()
127+ {
128+ $ gitDir = __DIR__ .'/test-git ' ;
129+ @mkdir ($ gitDir );
130+ chdir ($ gitDir );
131+ exec ('git init ' );
132+ exec ('git config user.name test ' );
133+ exec ('git config user.email test@example.com ' );
134+ file_put_contents ($ gitDir .'/composer.lock ' , file_get_contents (__DIR__ .'/fixtures/base/composer.lock ' ));
135+ exec ('git add composer.lock && git commit -m "init" ' );
136+ file_put_contents ($ gitDir .'/composer.lock ' , file_get_contents (__DIR__ .'/fixtures/target/composer.lock ' ));
137+ }
138+
126139 private function operationToString (OperationInterface $ operation )
127140 {
128141 if ($ operation instanceof InstallOperation) {
0 commit comments