Skip to content

Commit c81c1b6

Browse files
committed
[PhpUnitBridge] Fix class_alias() for PHPUnit\Framework\Error\Error
PHPUnit 6.x removed the PHPUnit_Framework_* classes in favor of PHP namespaces, but one error class did not map the same as the others: `PHPUnit_Framework_Error`. Instead of mapping to `PHPUnit\Framework\Error` in the same way that `PHPUnit_Framework_Error_Warning` mapped to `PHPUnit\Framework\Error\Warning`, this base class was replaced with `PHPUnit\Framework\Error\Error`.
1 parent edad555 commit c81c1b6

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Tests/BootstrapTest.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
class BootstrapTest extends TestCase
17+
{
18+
/**
19+
* @requires PHPUnit < 6.0
20+
*/
21+
public function testAliasingOfErrorClasses()
22+
{
23+
$this->assertInstanceOf(
24+
\PHPUnit_Framework_Error::class,
25+
new \PHPUnit\Framework\Error\Error('message', 0, __FILE__, __LINE__)
26+
);
27+
$this->assertInstanceOf(
28+
\PHPUnit_Framework_Error_Deprecated::class,
29+
new \PHPUnit\Framework\Error\Deprecated('message', 0, __FILE__, __LINE__)
30+
);
31+
$this->assertInstanceOf(
32+
\PHPUnit_Framework_Error_Notice::class,
33+
new \PHPUnit\Framework\Error\Notice('message', 0, __FILE__, __LINE__)
34+
);
35+
$this->assertInstanceOf(
36+
\PHPUnit_Framework_Error_Warning::class,
37+
new \PHPUnit\Framework\Error\Warning('message', 0, __FILE__, __LINE__)
38+
);
39+
}
40+
}

bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
'PHPUnit_Framework_Constraint_TraversableContains',
5757
'PHPUnit_Framework_Constraint_TraversableContainsOnly',
5858

59-
'PHPUnit_Framework_Error',
6059
'PHPUnit_Framework_Error_Deprecated',
6160
'PHPUnit_Framework_Error_Notice',
6261
'PHPUnit_Framework_Error_Warning',
@@ -100,6 +99,7 @@ class_alias('PHPUnit_Framework_Constraint_And', 'PHPUnit\Framework\Constraint\Lo
10099
class_alias('PHPUnit_Framework_Constraint_Not', 'PHPUnit\Framework\Constraint\LogicalNot');
101100
class_alias('PHPUnit_Framework_Constraint_Or', 'PHPUnit\Framework\Constraint\LogicalOr');
102101
class_alias('PHPUnit_Framework_Constraint_Xor', 'PHPUnit\Framework\Constraint\LogicalXor');
102+
class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error');
103103
}
104104

105105
// Detect if we need to serialize deprecations to a file.

0 commit comments

Comments
 (0)