8000 [PhpUnitBridge] Fix some errors when using serialized deprecations by l-vo · Pull Request #31478 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PhpUnitBridge] Fix some errors when using serialized deprecations #31478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

10000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[PhpUnitBridge] Fix error when setting "self" property value
  • Loading branch information
l-vo committed Jun 2, 2019
commit 09bd6b73ec61e1dd77ba3879754c51b056b2a67b
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function __construct($message, array $trace, $file)
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
// then we need to use the serialized information to determine
// if the error has been triggered from vendor code.
$this->self = isset($parsedMsg['triggering_file'])
&& $this->pathOriginatesFromVendor($parsedMsg['triggering_file']);
$this->self = !isset($parsedMsg['triggering_file'])
|| !$this->pathOriginatesFromVendor($parsedMsg['triggering_file']);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5;

class DeprecationTest extends TestCase
{
Expand Down Expand Up @@ -49,9 +50,60 @@ public function testItRulesOutFilesOutsideVendorsAsIndirect()
$this->assertFalse($deprecation->isIndirect());
}

public function providerIsSelf(): array
{
return [
'not_from_vendors_file' => [true, '', 'MyClass1', ''],
'nonexistent_file' => [false, '', 'MyClass1', 'dummy_vendor_path'],
'serialized_trace_without_triggering_file' => [
true,
serialize(['class' => '', 'method' => '', 'deprecation' => '', 'files_stack' => []]),
SymfonyTestsListenerForV5::class,
'',
],
'serialized_trace_with_not_from_vendors_triggering_file' => [
true,
serialize([
'class' => '',
'method' => '',
'deprecation' => '',
'triggering_file' => '',
'files_stack' => [],
]),
SymfonyTestsListenerForV5::class,
'',
],
'serialized_trace_with_nonexistent_triggering_file' => [
false,
serialize([
'class' => '',
'method' => '',
'deprecation' => '',
'triggering_file' => 'dummy_vendor_path',
'files_stack' => [],
]),
SymfonyTestsListenerForV5::class,
'',
],
];
}

/**
* @dataProvider providerIsSelf
*/
public function testIsSelf(bool $expectedIsSelf, string $message, string $traceClass, string $file): void
{
$trace = [
['class' => 'MyClass1', 'function' => 'myMethod'],
['class' => $traceClass, 'function' => 'myMethod'],
];
$deprecation = new Deprecation($message, $trace, $file);
$this->assertEquals($expectedIsSelf, $deprecation->isSelf());
}

/**
* This method is here to simulate the extra level from the piece of code
* triggering an error to the error handler
* triggering an error to the error handler.
*/
public function debugBacktrace(): array
{
Expand Down
0