-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathAddInspectCommandIntegrationTest.php
132 lines (103 loc) · 3.08 KB
/
AddInspectCommandIntegrationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
declare(strict_types=1);
/*
* This file is part of the humbug/php-scoper package.
*
* Copyright (c) 2017 Théo FIDRY <theo.fidry@gmail.com>,
* Pádraic Brady <padraic.brady@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Console\Command;
use Fidry\Console\ExitCode;
use Fidry\Console\Test\AppTester;
use Fidry\Console\Test\OutputAssertions;
use Humbug\PhpScoper\Console\Application;
use Humbug\PhpScoper\Container;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function Safe\preg_replace;
/**
* @internal
*/
#[Group('integration')]
#[CoversNothing]
class AddInspectCommandIntegrationTest extends TestCase
{
private const FIXTURE_PATH = __DIR__.'/../../../fixtures/set002/original';
private AppTester $appTester;
protected function setUp(): void
{
parent::setUp();
$application = new Application(
new Container(),
'TestVersion',
'28/01/2020',
false,
false,
);
$this->appTester = AppTester::fromConsoleApp($application);
}
public function test_it_shows_the_scoped_content_of_the_file_given(): void
{
$input = [
'inspect',
'--prefix' => 'MyPrefix',
'file-path' => self::FIXTURE_PATH.'/file.php',
'--no-interaction' => null,
'--no-config' => null,
];
$this->appTester->run($input);
OutputAssertions::assertSameOutput(
<<<'PHP'
Scoped contents:
"""
<?php
declare (strict_types=1);
namespace MyPrefix\MyNamespace;
"""
Symbols Registry:
"""
Humbug\PhpScoper\Symbol\SymbolsRegistry {#140
-recordedFunctions: []
-recordedClasses: []
}
"""
PHP,
ExitCode::SUCCESS,
$this->appTester,
self::normalizeSymbolsRegistryReference(...),
);
}
public function test_it_shows_the_raw_scoped_content_of_the_file_given_in_quiet_mode(): void
{
$input = [
'inspect',
'--prefix' => 'MyPrefix',
'file-path' => self::FIXTURE_PATH.'/file.php',
'--no-interaction' => null,
'--no-config' => null,
'--quiet' => null,
];
$this->appTester->run($input);
OutputAssertions::assertSameOutput(
<<<'PHP'
<?php
declare (strict_types=1);
namespace MyPrefix\MyNamespace;
PHP,
ExitCode::SUCCESS,
$this->appTester,
);
}
private static function normalizeSymbolsRegistryReference(string $output): string
{
return preg_replace(
'/ \{#\d{3,}/',
' {#140',
$output,
);
}
}