Skip to content

Commit ad793e6

Browse files
committed
keep test-git dir
1 parent 1d1f399 commit ad793e6

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/.php_cs.cache
44
/.php_cs
55
/tests/fixtures/**/vendor/
6+
/tests/test-git/

tests/PackageDiffTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
class 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

Comments
 (0)