Skip to content

Commit 5ef437b

Browse files
Merge branch '4.3' into 4.4
* 4.3: Minor fixes [HttpClient] Minor fixes Use namespaced Phpunit classes [Messenger] Fixed ConsumeMessagesCommand configuration [Form] remove leftover int child phpdoc Support DateTimeInterface in IntlDateFormatter::format [PhpUnitBridge] fixed PHPUnit 8.3 compatibility: method handleError was renamed to __invoke fixed phpdocs Use PHPunit assertion [Intl] Order alpha2 to alpha3 mapping + phpdoc fixes
2 parents e769d52 + d4df6cf commit 5ef437b

File tree

29 files changed

+130
-115
lines changed

29 files changed

+130
-115
lines changed

.php_cs.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ return PhpCsFixer\Config::create()
99
'@Symfony' => true,
1010
'@Symfony:risky' => true,
1111
'@PHPUnit75Migration:risky' => true,
12-
'php_unit_dedicate_assert' => ['target' => '3.5'],
12+
'php_unit_dedicate_assert' => ['target' => '5.6'],
1313
'phpdoc_no_empty_return' => false, // triggers almost always false positive
1414
'array_syntax' => ['syntax' => 'short'],
1515
'fopen_flags' => false,

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ install:
196196
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
197197
SYMFONY_VERSION=$(cat src/Symfony/Bridge/PhpUnit/composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
198198
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json
199+
rm -rf .phpunit
199200
fi
200201
201202
- |

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

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

1212
namespace Symfony\Bridge\PhpUnit;
1313

14+
use PHPUnit\Framework\TestResult;
1415
use PHPUnit\Util\ErrorHandler;
1516
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
1617
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
@@ -49,6 +50,7 @@ class DeprecationErrorHandler
4950
];
5051

5152
private static $isRegistered = false;
53+
private static $isAtLeastPhpUnit83;
5254

5355
/**
5456
* Registers and configures the deprecation handler.
@@ -72,13 +74,15 @@ public static function register($mode = 0)
7274
return;
7375
}
7476

77+
self::$isAtLeastPhpUnit83 = !class_exists('PHPUnit_Util_ErrorHandler') && method_exists(ErrorHandler::class, '__invoke');
78+
7579
$handler = new self();
7680
$oldErrorHandler = set_error_handler([$handler, 'handleError']);
7781

7882
if (null !== $oldErrorHandler) {
7983
restore_error_handler();
8084

81-
if ([ErrorHandler::class, 'handleError'] === $oldErrorHandler) {
85+
if ($oldErrorHandler instanceof ErrorHandler || [ErrorHandler::class, 'handleError'] === $oldErrorHandler) {
8286
restore_error_handler();
8387
self::register($mode);
8488
}
@@ -98,7 +102,7 @@ public static function collectDeprecations($outputFile)
98102
return $previousErrorHandler($type, $msg, $file, $line, $context);
99103
}
100104

101-
return ErrorHandler::handleError($type, $msg, $file, $line, $context);
105+
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
102106
}
103107

104108
$deprecations[] = [error_reporting(), $msg, $file];
@@ -115,7 +119,7 @@ public static function collectDeprecations($outputFile)
115119
public function handleError($type, $msg, $file, $line, $context = [])
116120
{
117121
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || !$this->getConfiguration()->isEnabled()) {
118-
return ErrorHandler::handleError($type, $msg, $file, $line, $context);
122+
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
119123
}
120124

121125
$deprecation = new Deprecation($msg, debug_backtrace(), $file);
@@ -310,6 +314,26 @@ private function displayDeprecations($groups, $configuration)
310314
}
311315
}
312316

317+
private static function getPhpUnitErrorHandler()
318+
{
319+
if (!self::$isAtLeastPhpUnit83) {
320+
return 'PHPUnit\Util\ErrorHandler::handleError';
321+
}
322+
323+
foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
324+
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
325+
return new ErrorHandler(
326+
$frame['object']->getConvertDeprecationsToExceptions(),
327+
$frame['object']->getConvertErrorsToExceptions(),
328+
$frame['object']->getConvertNoticesToExceptions(),
329+
$frame['object']->getConvertWarningsToExceptions()
330+
);
331+
}
332+
}
333+
334+
return function () { return false; };
335+
}
336+
313337
/**
314338
* Returns true if STDOUT is defined and supports colorization.
315339
*

src/Symfony/Bridge/PhpUnit/Legacy/PolyfillTestCaseTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use PHPUnit\Framework\TestCase;
1616

1717
/**
18-
* This trait is @internal
18+
* This trait is @internal.
1919
*/
2020
trait PolyfillTestCaseTrait
2121
{

src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testIsolation()
2424

2525
public function testCallingOtherErrorHandler()
2626
{
27-
$this->expectException(\class_exists('PHPUnit_Framework_Exception') ? 'PHPUnit_Framework_Exception' : 'PHPUnit\Framework\Exception');
27+
$this->expectException('PHPUnit\Framework\Exception');
2828
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
2929

3030
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
15011501
->info('A comma separated list of hosts that do not require a proxy to be reached.')
15021502
->end()
15031503
->floatNode('timeout')
1504-
->info('Defaults to "default_socket_timeout" ini parameter.')
1504+
->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
15051505
->end()
15061506
->scalarNode('bindto')
15071507
->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function testProcessForAutoconfiguredCalls()
233233
public function testProcessThrowsExceptionForArguments()
234234
{
235235
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
236-
$this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines arguments but these are not supported and should be removed.');
236+
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
237237
$container = new ContainerBuilder();
238238
$container->registerForAutoconfiguration(parent::class)
239239
->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/ErrorRenderer/Tests/Exception/FlattenExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function () {},
294294

295295
// assertEquals() does not like NAN values.
296296
$this->assertEquals($array[$i][0], 'float');
297-
$this->assertTrue(is_nan($array[$i++][1]));
297+
$this->assertNan($array[$i++][1]);
298298
}
299299

300300
public function testRecursionInArguments()

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist()
153153

154154
$this->filesystem->copy($sourceFilePath, $targetFilePath);
155155

156-
$this->assertTrue(is_dir($targetFileDirectory));
156+
$this->assertDirectoryExists($targetFileDirectory);
157157
$this->assertFileExists($targetFilePath);
158158
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
159159
}
@@ -185,7 +185,7 @@ public function testMkdirCreatesDirectoriesRecursively()
185185

186186
$this->filesystem->mkdir($directory);
187187

188-
$this->assertTrue(is_dir($directory));
188+
$this->assertDirectoryExists($directory);
189189
}
190190

191191
public function testMkdirCreatesDirectoriesFromArray()
@@ -197,9 +197,9 @@ public function testMkdirCreatesDirectoriesFromArray()
197197

198198
$this->filesystem->mkdir($directories);
199199

200-
$this->assertTrue(is_dir($basePath.'1'));
201-
$this->assertTrue(is_dir($basePath.'2'));
202-
$this->assertTrue(is_dir($basePath.'3'));
200+
$this->assertDirectoryExists($basePath.'1');
201+
$this->assertDirectoryExists($basePath.'2');
202+
$this->assertDirectoryExists($basePath.'3');
203203
}
204204

205205
public function testMkdirCreatesDirectoriesFromTraversableObject()
@@ -211,9 +211,9 @@ public function testMkdirCreatesDirectoriesFromTraversableObject()
211211

212212
$this->filesystem->mkdir($directories);
213213

214-
$this->assertTrue(is_dir($basePath.'1'));
215-
$this->assertTrue(is_dir($basePath.'2'));
216-
$this->assertTrue(is_dir($basePath.'3'));
214+
$this->assertDirectoryExists($basePath.'1');
215+
$this->assertDirectoryExists($basePath.'2');
216+
$this->assertDirectoryExists($basePath.'3');
217217
}
218218

219219
public function testMkdirCreatesDirectoriesFails()
@@ -347,7 +347,7 @@ public function testRemoveCleansInvalidLinks()
347347

348348
// create symlink to dir using trailing forward slash
349349
$this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
350-
$this->assertTrue(is_dir($basePath.'dir-link'));
350+
$this->assertDirectoryExists($basePath.'dir-link');
351351

352352
// create symlink to nonexistent dir
353353
rmdir($basePath.'dir');
@@ -821,7 +821,7 @@ public function testRemoveSymlink()
821821

822822
$this->assertFalse(is_link($link));
823823
$this->assertFalse(is_file($link));
824-
$this->assertFalse(is_dir($link));
824+
$this->assertDirectoryNotExists($link);
825825
}
826826

827827
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
@@ -1150,8 +1150,8 @@ public function testMirrorCopiesFilesAndDirectoriesRecursively()
11501150

11511151
$this->filesystem->mirror($sourcePath, $targetPath);
11521152

1153-
$this->assertTrue(is_dir($targetPath));
1154-
$this->assertTrue(is_dir($targetPath.'directory'));
1153+
$this->assertDirectoryExists($targetPath);
1154+
$this->assertDirectoryExists($targetPath.'directory');
11551155
$this->assertFileEquals($file1, $targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1');
11561156
$this->assertFileEquals($file2, $targetPath.'file2');
11571157

@@ -1184,7 +1184,7 @@ public function testMirrorCreatesEmptyDirectory()
11841184

11851185
$this->filesystem->mirror($sourcePath, $targetPath);
11861186

1187-
$this->assertTrue(is_dir($targetPath));
1187+
$this->assertDirectoryExists($targetPath);
11881188

11891189
$this->filesystem->remove($sourcePath);
11901190
}
@@ -1203,7 +1203,7 @@ public function testMirrorCopiesLinks()
12031203

12041204
$this->filesystem->mirror($sourcePath, $targetPath);
12051205

1206-
$this->assertTrue(is_dir($targetPath));
1206+
$this->assertDirectoryExists($targetPath);
12071207
$this->assertFileEquals($sourcePath.'file1', $targetPath.'link1');
12081208
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
12091209
}
@@ -1223,7 +1223,7 @@ public function testMirrorCopiesLinkedDirectoryContents()
12231223

12241224
$this->filesystem->mirror($sourcePath, $targetPath);
12251225

1226-
$this->assertTrue(is_dir($targetPath));
1226+
$this->assertDirectoryExists($targetPath);
12271227
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
12281228
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
12291229
}
@@ -1247,7 +1247,7 @@ public function testMirrorCopiesRelativeLinkedContents()
12471247

12481248
$this->filesystem->mirror($sourcePath, $targetPath);
12491249

1250-
$this->assertTrue(is_dir($targetPath));
1250+
$this->assertDirectoryExists($targetPath);
12511251
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
12521252
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
12531253
$this->assertEquals('\\' === \DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.\DIRECTORY_SEPARATOR.'link1'));
@@ -1270,7 +1270,7 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithoutDeleteOptio
12701270

12711271
chdir($oldPath);
12721272

1273-
$this->assertTrue(is_dir($targetPath));
1273+
$this->assertDirectoryExists($targetPath);
12741274
$this->assertFileExists($targetPath.'source');
12751275
$this->assertFileExists($targetPath.'target');
12761276
}
@@ -1295,7 +1295,7 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption()
12951295

12961296
chdir($oldPath);
12971297

1298-
$this->assertTrue(is_dir($targetPath));
1298+
$this->assertDirectoryExists($targetPath);
12991299
$this->assertFileExists($targetPath.'source');
13001300
$this->assertFileNotExists($targetPath.'target');
13011301
}

0 commit comments

Comments
 (0)