8000 Test · symfony/symfony@a2af18a · GitHub
[go: up one dir, main page]

Skip to content

Commit a2af18a

Browse files
committed
Test
1 parent 2835bcb commit a2af18a

File tree

1 file changed

+1
-141
lines changed

1 file changed

+1
-141
lines changed

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 1 addition & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,11 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler;
1313

14-
use Composer\Autoload\ClassLoader;
1514
use PHPUnit\Framework\TestCase;
1615
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
17-
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5;
1816

1917
class DeprecationTest extends TestCase
2018
{
21-
public static function setUpBeforeClass(): void
22-
{
23-
$vendorDir = self::getVendorDir();
24-
25-
mkdir($vendorDir.'/myfakevendor/myfakepackage1', 0777, true);
26-
mkdir($vendorDir.'/myfakevendor/myfakepackage2');
27-
touch($vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile1.php');
28-
touch($vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile2.php');
29-
touch($vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php');
30-
}
31-
32-
private static function getVendorDir(): string
33-
{
34-
$reflection = new \ReflectionClass(ClassLoader::class);
35-
return dirname($reflection->getFileName(), 2);
36-
}
37-
3819
public function testItCanDetermineTheClassWhereTheDeprecationHappened()
3920
{
4021
$deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
@@ -68,133 +49,12 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect()
6849
$this->assertFalse($deprecation->isIndirect());
6950
}
7051

71-
public function providerIsSelf(): array
72-
{
73-
return [
74-
[true, '', 'MyClass1', ''],
75-
[false, '', 'MyClass1', 'dummy_vendor_path'],
76-
[
77-
true,
78-
serialize(['class' => '', 'method' => '', 'deprecation' => '', 'files_stack' => []]),
79-
SymfonyTestsListenerForV5::class,
80-
'',
81-
],
82-
[
83-
true,
84-
serialize([
85-
'class' => '',
86-
'method' => '',
87-
'deprecation' => '',
88-
'triggering_file' => '',
89-
'files_stack' => [],
90-
]),
91-
SymfonyTestsListenerForV5::class,
92-
'',
93-
],
94-
[
95-
false,
96-
serialize([
97-
'class' => '',
98-
'method' => '',
99-
'deprecation' => '',
100-
'triggering_file' => 'dummy_vendor_path',
101-
'files_stack' => [],
102-
]),
103-
SymfonyTestsListenerForV5::class,
104-
'',
105-
],
106-
];
107-
}
108-
109-
/**
110-
* @dataProvider providerIsSelf
111-
*/
112-
/*public function testIsSelf(bool $expectedIsSelf, string $message, string $traceClass, string $file): void
113-
{
114-
$trace = [
115-
['class' => 'MyClass1', 'function' => 'myMethod'],
116-
['class' => $traceClass, 'function' => 'myMethod'],
117-
];
118-
$deprecation = new Deprecation($message, $trace, $file);
119-
$this->assertEquals($expectedIsSelf, $deprecation->isSelf());
120-
}*/
121-
122-
public function providerIsIndirectUsesRightTrace(): array
123-
{
124-
$vendorDir = self::getVendorDir();
125-
126-
return [
127-
'no_file_in_stack' => [false, '', [['function' => 'myfunc1'], ['function' => 'myfunc2']]],
128-
'files_in_stack_from_various_packages' => [
129-
true,
130-
'',
131-
[
132-
['function' => 'myfunc1', 'file' => $vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile1.php'],
133-
['function' => 'myfunc2', 'file' => $vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php'],
134-
],
135-
],
136-
'serialized_stack_files_from_same_package' => [
137-
false,
138-
serialize([
139-
'deprecation' => 'My deprecation message',
140-
'class' => 'MyClass',
141-
'method' => 'myMethod',
142-
'files_stack' => [
143-
$vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile1.php',
144-
$vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile2.php',
145-
],
146-
]),
147-
[['function' => 'myfunc1'], ['class' => SymfonyTestsListenerForV5::class, 'method' => 'mymethod']],
148-
],
149-
'serialized_stack_files_from_various_packages' => [
150-
true,
151-
serialize([
152-
'deprecation' => 'My deprecation message',
153-
'class' => 'MyClass',
154-
'method' => 'myMethod',
155-
'files_stack' => [
156-
$vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile1.php',
157-
$vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php',
158-
],
159-
]),
160-
[['function' => 'myfunc1'], ['class' => SymfonyTestsListenerForV5::class, 'method' => 'mymethod']],
161-
],
162-
];
163-
}
164-
165-
/**
166-
* @dataProvider providerIsIndirectUsesRightTrace
167-
*/
168-
/*public function testIsIndirectUsesRightTrace(bool $expectedIsIndirect, string $message, array $trace): void
169-
{
170-
$deprecation = new Deprecation($message, $trace, '');
171-
$this->assertEquals($expectedIsIndirect, $deprecation->isIndirect());
172-
}*/
173-
17452
/**
17553
* This method is here to simulate the extra level from the piece of code
176-
* triggering an error to the error handler.
54+
* triggering an error to the error handler
17755
*/
17856
public function debugBacktrace(): array
17957
{
18058
return debug_backtrace();
18159
}
182-
183-
private static function removeDir($dir): void
184-
{
185-
$files = glob($dir.'/*');
186-
foreach ($files as $file) {
187-
if (is_file($file)) {
188-
unlink($file);
189-
} else {
190-
self::removeDir($file);
191-
}
192-
}
193-
rmdir($dir);
194-
}
195-
196-
public static function tearDownAfterClass(): void
197-
{
198-
self::removeDir(self::getVendorDir().'/myfakevendor');
199-
}
20060
}

0 commit comments

Comments
 (0)
0