Merge branch '3.1'
* 3.1: Tweak merge update tests to use the new error assertion helper [ci] Upgrade to symfony/phpunit-bridge >=3.2@dev update tests to use the new error assertion helper Conflicts: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
This commit is contained in:
commit
9a6bc4bc31
2
phpunit
2
phpunit
@ -56,7 +56,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
|
||||
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
|
||||
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
|
||||
}
|
||||
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\"");
|
||||
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.2@dev\"");
|
||||
passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit);
|
||||
if ($exit) {
|
||||
exit($exit);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
|
||||
use Symfony\Component\Cache\Adapter\ApcuAdapter;
|
||||
@ -541,25 +542,12 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
*/
|
||||
public function testDeprecatedSerializerCacheOption()
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
});
|
||||
|
||||
ErrorAssert::assertDeprecationsAreTriggered('The "framework.serializer.cache" option is deprecated', function () {
|
||||
$container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__));
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('The "framework.serializer.cache" option is deprecated', $deprecations[0]);
|
||||
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
|
||||
$this->assertEquals(new Reference('foo'), $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1));
|
||||
});
|
||||
}
|
||||
|
||||
public function testAssetHelperWhenAssetsAreEnabled()
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
@ -88,26 +89,13 @@ class TemplateNameParserTest extends TestCase
|
||||
*/
|
||||
public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref)
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
});
|
||||
|
||||
ErrorAssert::assertDeprecationsAreTriggered('Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.', function () use ($name, $logicalName, $path, $ref) {
|
||||
$template = $this->parser->parse($name);
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
|
||||
$this->assertSame($logicalName, $template->getLogicalName());
|
||||
$this->assertSame($path, $template->getPath());
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.', $deprecations[0]);
|
||||
});
|
||||
}
|
||||
|
||||
public function provideAbsolutePaths()
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\DependencyInjection\Tests;
|
||||
require_once __DIR__.'/Fixtures/includes/classes.php';
|
||||
require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Component\Config\Resource\ResourceInterface;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@ -58,31 +59,15 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCreateDeprecatedService()
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
});
|
||||
|
||||
ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () {
|
||||
$definition = new Definition('stdClass');
|
||||
$definition->setDeprecated(true);
|
||||
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->setDefinition('deprecated_foo', $definition);
|
||||
|
||||
$builder->compile();
|
||||
|
||||
$builder->get('deprecated_foo');
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]);
|
||||
});
|
||||
}
|
||||
|
||||
public function testRegister()
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Loader;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
@ -546,29 +547,19 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAliasDefinitionContainsUnsupportedElements()
|
||||
{
|
||||
$deprecations = array(
|
||||
'Using the attribute "class" is deprecated for alias definition "bar"',
|
||||
'Using the element "tag" is deprecated for alias definition "bar"',
|
||||
'Using the element "factory" is deprecated for alias definition "bar"',
|
||||
);
|
||||
|
||||
ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () {
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
});
|
||||
|
||||
$loader->load('legacy_invalid_alias_definition.xml');
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertTrue($container->has('bar'));
|
||||
|
||||
$this->assertCount(3, $deprecations);
|
||||
$this->assertContains('Using the attribute "class" is deprecated for alias definition "bar"', $deprecations[0]);
|
||||
$this->assertContains('Using the element "tag" is deprecated for alias definition "bar"', $deprecations[1]);
|
||||
$this->assertContains('Using the element "factory" is deprecated for alias definition "bar"', $deprecations[2]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\Fragment;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerReference;
|
||||
use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Esi;
|
||||
@ -30,29 +31,12 @@ class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testRenderFallbackWithObjectAttributesIsDeprecated()
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $message) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $message;
|
||||
});
|
||||
|
||||
ErrorAssert::assertDeprecationsAreTriggered('Passing objects as part of URI attributes to the ESI and SSI rendering strategies is deprecated', function () {
|
||||
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo'));
|
||||
|
||||
$request = Request::create('/');
|
||||
|
||||
$reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array());
|
||||
|
||||
$strategy->render($reference, $request);
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('Passing objects as part of URI attributes to the ESI and SSI rendering strategies is deprecated', $deprecations[0]);
|
||||
});
|
||||
}
|
||||
|
||||
public function testRender()
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
@ -258,23 +259,9 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithPercentCharacter()
|
||||
{
|
||||
$deprecations = array();
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED !== $type) {
|
||||
restore_error_handler();
|
||||
|
||||
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
|
||||
}
|
||||
|
||||
$deprecations[] = $msg;
|
||||
});
|
||||
|
||||
ErrorAssert::assertDeprecationsAreTriggered('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () {
|
||||
Inline::parse('{ foo: %foo }');
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $deprecations[0]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
|
Reference in New Issue
Block a user