8000 minor #32941 Use namespaced Phpunit classes (jderusse) · symfony/symfony@f752416 · GitHub
[go: up one dir, main page]

Skip to content

Commit f752416

Browse files
minor #32941 Use namespaced Phpunit classes (jderusse)
This PR was squashed before being merged into the 3.4 branch (closes #32941). Discussion ---------- Use namespaced Phpunit classes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | need #32940 | Fixed tickets | #32844 | License | MIT | Doc PR | NA This PR simplify tests by using PhpUnit namespace introduced in #32940 It also makes compatible with PHPUnit 8 (removed class PHPUnit_Framework_MockObject_MockObject) Commits ------- 797ea2e Use namespaced Phpunit classes
2 parents cf459e5 + 797ea2e commit f752416

File tree

9 files changed

+15
-46
lines changed
8000

9 files changed

+15
-46
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ install:
209209
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
210210
SYMFONY_VERSION=$(cat src/Symfony/Bridge/PhpUnit/composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
211211
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json
212+
rm -rf .phpunit
212213
fi
213214
214215
- |

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInstanceofConditionalsPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function testBadInterfaceForAutomaticInstanceofIsOk()
201201
public function testProcessThrowsExceptionForAutoconfiguredCalls()
202202
{
203203
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
204-
$this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines method calls but these are not supported and should be removed.');
204+
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines method calls but these are not supported and should be removed\./');
205205
$container = new ContainerBuilder();
206206
$container->registerForAutoconfiguration(parent::class)
207207
->addMethodCall('setFoo');
@@ -212,7 +212,7 @@ public function testProcessThrowsExceptionForAutoconfiguredCalls()
212212
public function testProcessThrowsExceptionForArguments()
213213
{
214214
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
215-
$this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines arguments but these are not supported and should be removed.');
215+
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
216216
$container = new ContainerBuilder();
217217
$container->registerForAutoconfiguration(parent::class)
218218
->addArgument('bar');

src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Tests\Config;
1313

14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Config\ResourceCheckerInterface;
1617
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
@@ -52,15 +53,15 @@ public function testIsFresh(callable $mockContainer, $expected)
5253

5354
public function isFreshProvider()
5455
{
55-
yield 'not fresh on missing parameter' => [function (\PHPUnit_Framework_MockObject_MockObject $container) {
56+
yield 'not fresh on missing parameter' => [function (MockObject $container) {
5657
$container->method('hasParameter')->with('locales')->willReturn(false);
5758
}, false];
5859

59-
yield 'not fresh on different value' => [function (\PHPUnit_Framework_MockObject_MockObject $container) {
60+
yield 'not fresh on different value' => [function (MockObject $container) {
6061
$container->method('getParameter')->with('locales')->willReturn(['nl', 'es']);
6162
}, false];
6263

63-
yield 'fresh on every identical parameters' => [function (\PHPUnit_Framework_MockObject_MockObject $container) {
64+
yield 'fresh on every identical parameters' => [function (MockObject $container) {
6465
$container->expects($this->exactly(2))->method('hasParameter')->willReturn(true);
6566
$container->expects($this->exactly(2))->method('getParameter')
6667
->withConsecutive(

src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase
2020
*/
2121
public function testTranslationFileIsValid($filePath)
2222
{
23-
if (class_exists('PHPUnit_Util_XML')) {
24-
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
25-
} else {
26-
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
27-
}
23+
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
2824

2925
$this->addToAssertionCount(1);
3026
}

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testProcess()
2626
$resolver = $container->register('argument_resolver.service')->addArgument([]);
2727

2828
$container->register('stdClass', 'stdClass');
29-
$container->register(parent::class, 'stdClass');
29+
$container->register(TestCase::class, 'stdClass');
3030
$container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments');
3131
$container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments')
3232
->addMethodCall('setTestCase', [new Reference('c1')]);

src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Intl\Tests\NumberFormatter;
1313

14+
use PHPUnit\Framework\Error\Warning;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Intl\Globals\IntlGlobals;
1617
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
@@ -323,13 +324,7 @@ public function formatTypeDoubleWithCurrencyStyleProvider()
323324
*/
324325
public function testFormatTypeCurrency($formatter, $value)
325326
{
326-
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
327-
328-
if (class_exists('PHPUnit_Framework_Error_Warning')) {
329-
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
330-
}
331-
332-
$this->expectException($exceptionCode);
327+
$this->expectException(Warning::class);
333328

334329
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
335330
}
@@ -706,13 +701,7 @@ public function parseProvider()
706701

707702
public function testParseTypeDefault()
708703
{
709-
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
710-
711-
if (class_exists('PHPUnit_Framework_Error_Warning')) {
712-
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
713-
}
714-
715-
$this->expectException($exceptionCode);
704+
$this->expectException(Warning::class);
716705

717706
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
718707
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
@@ -832,13 +821,7 @@ public function parseTypeDoubleProvider()
832821

833822
public function testParseTypeCurrency()
834823
{
835-
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
836-
837-
if (class_exists('PHPUnit_Framework_Error_Warning')) {
838-
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
839-
}
840-
841-
$this->expectException($exceptionCode);
824+
$this->expectException(Warning::class);
842825

843826
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
844827
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);

src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase
2020
*/
2121
public function testTranslationFileIsValid($filePath)
2222
{
23-
if (class_exists('PHPUnit_Util_XML')) {
24-
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
25-
} else {
26-
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
27-
}
23+
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
2824

2925
$this->addToAssertionCount(1);
3026
}

src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase
2020
*/
2121
public function testTranslationFileIsValid($filePath)
2222
{
23-
if (class_exists('PHPUnit_Util_XML')) {
24-
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
25-
} else {
26-
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
27-
}
23+
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
2824

2925
$this->addToAssertionCount(1);
3026
}
920F

src/Symfony/Component/Yaml/Tests/ParserTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ public function testSpecifications($expected, $yaml, $comment, $deprecated)
4545
if (E_USER_DEPRECATED !== $type) {
4646
restore_error_handler();
4747

48-
if (class_exists('PHPUnit_Util_ErrorHandler')) {
49-
return \call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', \func_get_args());
50-
}
51-
5248
return \call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', \func_get_args());
5349
}
5450

0 commit comments

Comments
 (0)
0