1111
1212class PackageDiffTest extends TestCase
1313{
14- const TEST_GIT_DIR = __DIR__ .'/test-git ' ;
15- const FIXTURES_BASE = __DIR__ .'/fixtures/base ' ;
1614 /**
1715 * @param string[] $expected
1816 * @param bool $dev
@@ -24,23 +22,21 @@ public function testBasicUsage(array $expected, $dev, $withPlatform)
2422 {
2523 $ diff = new PackageDiff ();
2624 $ operations = $ diff ->getPackageDiff (
27- self :: FIXTURES_BASE . ' /composer.lock ' ,
28- self :: FIXTURES_TARGET . ' /composer.lock ' ,
25+ __DIR__ . ' /fixtures/base /composer.lock ' ,
26+ __DIR__ . ' /fixtures/target /composer.lock ' ,
2927 $ dev ,
3028 $ withPlatform
3129 );
3230
3331 $ this ->assertSame ($ expected , array_map (array ($ this , 'operationToString ' ), $ operations ));
3432 }
3533
36- const FIXTURES_TARGET = __DIR__ .'/fixtures/target ' ;
37-
3834 public function testSameBaseAndTarget ()
3935 {
4036 $ diff = new PackageDiff ();
4137 $ operations = $ diff ->getPackageDiff (
42- self :: FIXTURES_BASE . ' /composer.lock ' ,
43- self :: FIXTURES_BASE . ' /composer.lock ' ,
38+ __DIR__ . ' /fixtures/base /composer.lock ' ,
39+ __DIR__ . ' /fixtures/base /composer.lock ' ,
4440 true ,
4541 true
4642 );
@@ -57,12 +53,16 @@ public function testSameBaseAndTarget()
5753 */
5854 public function testGitUsage (array $ expected , $ dev , $ withPlatform )
5955 {
56+ $ gitDir = __DIR__ .'/test-git ' ;
6057 $ diff = new PackageDiff ();
61- chdir (self ::TEST_GIT_DIR );
58+ @mkdir ($ gitDir );
59+ chdir ($ gitDir );
6260 exec ('git init ' );
63- file_put_contents (self ::TEST_GIT_DIR .'/composer.lock ' , file_get_contents (self ::FIXTURES_BASE .'/composer.lock ' ));
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 ' ));
6464 exec ('git add composer.lock && git commit -m "init" ' );
65- file_put_contents (self :: TEST_GIT_DIR .'/composer.lock ' , file_get_contents (self :: FIXTURES_TARGET . ' /composer.lock ' ));
65+ file_put_contents ($ gitDir .'/composer.lock ' , file_get_contents (__DIR__ . ' /fixtures/target /composer.lock ' ));
6666 $ operations = $ diff ->getPackageDiff ('HEAD:composer.lock ' , 'composer.lock ' , $ dev , $ withPlatform );
6767
6868 $ this ->assertSame ($ expected , array_map (array ($ this , 'operationToString ' ), $ operations ));
0 commit comments