Skip to content

Commit bd39ce8

Browse files
Merge branch '2.8' into 3.0
* 2.8: update tests to use the new error assertion helper [ci] Upgrade to symfony/phpunit-bridge >=3.2@dev Conflicts: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php src/Symfony/Component/Yaml/Tests/ParserTest.php
2 parents d2786ad + f8937bd commit bd39ce8

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
5656
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
5757
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
5858
}
59-
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\"");
59+
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.2@dev\"");
6060
passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit);
6161
if ($exit) {
6262
exit($exit);

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
require_once __DIR__.'/Fixtures/includes/classes.php';
1515
require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
1616

17+
use Symfony\Bridge\PhpUnit\ErrorAssert;
1718
use Symfony\Component\Config\Resource\ResourceInterface;
1819
use Symfony\Component\DependencyInjection\Alias;
1920
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -60,28 +61,14 @@ public function testDefinitions()
6061

6162
public function testCreateDeprecatedService()
6263
{
63-
$deprecations = array();
64-
set_error_handler(function ($type, $msg) use (&$deprecations) {
65-
if (E_USER_DEPRECATED !== $type) {
66-
restore_error_handler();
64+
ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () {
65+
$definition = new Definition('stdClass');
66+
$definition->setDeprecated(true);
6767

68-
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
69-
}
70-
71-
$deprecations[] = $msg;
68+
$builder = new ContainerBuilder();
69+
$builder->setDefinition('deprecated_foo', $definition);
70+
$builder->get('deprecated_foo');
7271
});
73-
74-
$definition = new Definition('stdClass');
75-
$definition->setDeprecated(true);
76-
77-
$builder = new ContainerBuilder();
78-
$builder->setDefinition('deprecated_foo', $definition);
79-
$builder->get('deprecated_foo');
80-
81-
restore_error_handler();
82-
83-
$this->assertCount(1, $deprecations);
84-
$this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]);
8572
}
8673

8774
public function testRegister()

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

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

1212
namespace Symfony\Component\Yaml\Tests;
1313

14+
use Symfony\Bridge\PhpUnit\ErrorAssert;
1415
use Symfony\Component\Yaml\Yaml;
1516
use Symfony\Component\Yaml\Parser;
1617

@@ -930,11 +931,14 @@ public function testFloatKeys()
930931
*/
931932
public function testColonInMappingValueException()
932933
{
933-
$yaml = <<<EOF
934+
$parser = $this->parser;
935+
936+
ErrorAssert::assertDeprecationsAreTriggered('Using a colon in the unquoted mapping value "bar: baz" in line 1 is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', function () use ($parser) {
937+
$yaml = <<<EOF
934938
foo: bar: baz
935939
EOF;
936-
937-
$this->parser->parse($yaml);
940+
$parser->parse($yaml);
941+
});
938942
}
939943

940944
public function testColonInMappingValueExceptionNotTriggeredByColonInComment()

0 commit comments

Comments
 (0)