|
3 | 3 | use Xdevor\ComposerParser\Parser; |
4 | 4 |
|
5 | 5 | test('It can return correct value if key exist', function () { |
6 | | - $package = 'doctrine/instantiator'; |
7 | | - $illuminateSupportName = (new Parser())->parse($package, 'name'); |
8 | | - expect($illuminateSupportName)->toBe($package); |
| 6 | + $packageName = 'doctrine/instantiator'; |
| 7 | + $actual = (new Parser())->parse($packageName, 'name'); |
| 8 | + expect($actual)->toBe($packageName); |
9 | 9 | }); |
10 | 10 |
|
11 | | -test('It return default if key not exist', function () { |
12 | | - $package = 'ooo/xxx'; |
13 | | - $illuminateSupportName = (new Parser())->parse($package, 'name', null); |
14 | | - expect($illuminateSupportName)->toBe(null); |
| 11 | +test('It return null if key not exist', function () { |
| 12 | + $packageName = 'ooo/xxx'; |
| 13 | + $actual = (new Parser())->parse($packageName, 'name'); |
| 14 | + expect($actual)->toBe(null); |
| 15 | +}); |
| 16 | + |
| 17 | +test('It return default value if key not exist', function () { |
| 18 | + $packageName = 'ooo/xxx'; |
| 19 | + $actual = (new Parser())->parse($packageName, 'name', 'this_is_default'); |
| 20 | + expect($actual)->toBe('this_is_default'); |
15 | 21 | }); |
16 | 22 |
|
17 | 23 | test('It can return correct value if array key exist', function () { |
18 | | - $package = 'doctrine/instantiator'; |
19 | | - $illuminateSupportName = (new Parser())->parse($package, 'license.0'); |
20 | | - expect($illuminateSupportName)->toBe('MIT'); |
| 24 | + $packageName = 'doctrine/instantiator'; |
| 25 | + $actual = (new Parser())->parse($packageName, 'license.0'); |
| 26 | + expect($actual)->toBe('MIT'); |
| 27 | +}); |
| 28 | + |
| 29 | +test('It can use custom installed.json path', function () { |
| 30 | + $packageName = 'filp/whoops'; |
| 31 | + $actual = (new Parser(__DIR__ . '/../tests/assets/fakeInstalled.json'))->parse($packageName, 'extra.branch-alias.dev-master'); |
| 32 | + expect($actual)->toBe('2.7-dev'); |
21 | 33 | }); |
0 commit comments