Skip to content

Use namespaced Phpunit classes #32941

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

Merged
merged 1 commit into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ install:
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
SYMFONY_VERSION=$(cat src/Symfony/Bridge/PhpUnit/composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json
rm -rf .phpunit
fi

- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function testBadInterfaceForAutomaticInstanceofIsOk()
public function testProcessThrowsExceptionForAutoconfiguredCalls()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines method calls but these are not supported and should be removed.');
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines method calls but these are not supported and should be removed\./');
$container = new ContainerBuilder();
$container->registerForAutoconfiguration(parent::class)
->addMethodCall('setFoo');
Expand All @@ -212,7 +212,7 @@ public function testProcessThrowsExceptionForAutoconfiguredCalls()
public function testProcessThrowsExceptionForArguments()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines arguments but these are not supported and should be removed.');
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
$container = new ContainerBuilder();
$container->registerForAutoconfiguration(parent::class)
->addArgument('bar');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\DependencyInjection\Tests\Config;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\ResourceCheckerInterface;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
Expand Down Expand Up @@ -52,15 +53,15 @@ public function testIsFresh(callable $mockContainer, $expected)

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

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

yield 'fresh on every identical parameters' => [function (\PHPUnit_Framework_MockObject_MockObject $container) {
yield 'fresh on every identical parameters' => [function (MockObject $container) {
$container->expects($this->exactly(2))->method('hasParameter')->willReturn(true);
$container->expects($this->exactly(2))->method('getParameter')
->withConsecutive(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
}
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);

$this->addToAssertionCount(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testProcess()
$resolver = $container->register('argument_resolver.service')->addArgument([]);

$container->register('stdClass', 'stdClass');
$container->register(parent::class, 'stdClass');
$container->register(TestCase::class, 'stdClass');
$container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments');
$container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments')
->addMethodCall('setTestCase', [new Reference('c1')]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Intl\Tests\NumberFormatter;

use PHPUnit\Framework\Error\Warning;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Intl\Globals\IntlGlobals;
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
Expand Down Expand Up @@ -323,13 +324,7 @@ public function formatTypeDoubleWithCurrencyStyleProvider()
*/
public function testFormatTypeCurrency($formatter, $value)
{
$exceptionCode = 'PHPUnit\Framework\Error\Warning';

if (class_exists('PHPUnit_Framework_Error_Warning')) {
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
}

$this->expectException($exceptionCode);
$this->expectException(Warning::class);

$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
}
Expand Down Expand Up @@ -706,13 +701,7 @@ public function parseProvider()

public function testParseTypeDefault()
{
$exceptionCode = 'PHPUnit\Framework\Error\Warning';

if (class_exists('PHPUnit_Framework_Error_Warning')) {
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
}

$this->expectException($exceptionCode);
$this->expectException(Warning::class);

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

public function testParseTypeCurrency()
{
$exceptionCode = 'PHPUnit\Framework\Error\Warning';

if (class_exists('PHPUnit_Framework_Error_Warning')) {
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
}

$this->expectException($exceptionCode);
$this->expectException(Warning::class);

$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
}
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);

$this->addToAssertionCount(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
if (class_exists('PHPUnit_Util_XML')) {
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
} else {
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
}
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);

$this->addToAssertionCount(1);
}
Expand Down
4 changes: 0 additions & 4 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public function testSpecifications($expected, $yaml, $comment, $deprecated)
if (E_USER_DEPRECATED !== $type) {
restore_error_handler();

if (class_exists('PHPUnit_Util_ErrorHandler')) {
return \call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', \func_get_args());
}

return \call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', \func_get_args());
}

Expand Down