|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ComposerRequireCheckerTest\Cli; |
|
4
|
|
|
|
|
5
|
|
|
use ComposerRequireChecker\Cli\Application; |
|
6
|
|
|
use PHPUnit\Framework\TestCase; |
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
9
|
|
|
|
|
10
|
|
|
class CheckCommandTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var CommandTester |
|
15
|
|
|
*/ |
|
16
|
|
|
private $commandTester; |
|
17
|
|
|
|
|
18
|
|
|
public function setUp() |
|
19
|
|
|
{ |
|
20
|
|
|
$application = new Application(); |
|
21
|
|
|
$command = $application->get('check'); |
|
22
|
|
|
|
|
23
|
|
|
$this->commandTester = new CommandTester($command); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testExceptionIfComposerJsonNotFound() |
|
27
|
|
|
{ |
|
28
|
|
|
self::expectException(\InvalidArgumentException::class); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$this->commandTester->execute([ |
|
31
|
|
|
'composer-json' => 'this-will-not-be-found.json' |
|
32
|
|
|
]); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testSelfCheckShowsNoErrors() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->commandTester->execute([ |
|
38
|
|
|
// that's our own composer.json, lets be sure our self check does not throw errors |
|
39
|
|
|
'composer-json' => dirname(__DIR__, 3) . '/composer.json' |
|
40
|
|
|
]); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertSame(0, $this->commandTester->getStatusCode()); |
|
43
|
|
|
$this->assertContains('no unknown symbols found', $this->commandTester->getDisplay()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testVerboseSelfCheckShowsCounts() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->commandTester->execute([ |
|
49
|
|
|
// that's our own composer.json, lets be sure our self check does not throw errors |
|
50
|
|
|
'composer-json' => dirname(__DIR__, 3) . '/composer.json', |
|
51
|
|
|
], [ |
|
52
|
|
|
'verbosity' => OutputInterface::VERBOSITY_VERBOSE, |
|
53
|
|
|
]); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertRegExp('/Collecting defined vendor symbols... found \d+ symbols./', $this->commandTester->getDisplay()); |
|
56
|
|
|
$this->assertRegExp('/Collecting defined extension symbols... found \d+ symbols./', $this->commandTester->getDisplay()); |
|
57
|
|
|
$this->assertRegExp('/Collecting used symbols... found \d+ symbols./', $this->commandTester->getDisplay()); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|