8000 [3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation by nicolas-grekas · Pull Request #20268 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation #20268

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
Oct 21, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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;
Expand Down Expand Up @@ -547,16 +546,17 @@ public function testSerializerCacheDisabled()

/**
* @group legacy
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* @expectedDeprecation The "framework.serializer.cache" option is deprecated %s.
*/
public function testDeprecatedSerializerCacheOption()
{
ErrorAssert::assertDeprecationsAreTriggered('The "framework.serializer.cache" option is deprecated', function () {
$container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__));
$container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__));

$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
$this->assertEquals(new Reference('foo'), $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1));
});
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
$this->assertTrue($container->hasDefinition('serializer.mapping.class_metadata_factory'));

$cache = $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1);
$this->assertEquals(new Reference('foo'), $cache);
}

public function testAssetHelperWhenAssetsAreEnabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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;
Expand Down Expand Up @@ -86,17 +85,15 @@ public function testParseValidNameWithNotFoundBundle()
/**
* @group legacy
* @dataProvider provideAbsolutePaths
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* @expectedDeprecation Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.
*/
public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref)
{
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);
$template = $this->parser->parse($name);

$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
$this->assertSame($logicalName, $template->getLogicalName());
$this->assertSame($path, $template->getPath());
});
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
$this->assertSame($logicalName, $template->getLogicalName());
$this->assertSame($path, $template->getPath());
}

public function provideAbsolutePaths()
< 8000 /a> Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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;
Expand Down Expand Up @@ -59,18 +58,18 @@ public function testDefinitions()
}

/**
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* @group legacy
* @expectedDeprecation The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.
*/
public function testCreateDeprecatedService()
{
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);
$definition = new Definition('stdClass');
$definition->setDeprecated(true);

$builder = new ContainerBuilder();
$builder->setDefinition('deprecated_foo', $definition);
$builder->get('deprecated_foo');
});
$builder = new ContainerBuilder();
$builder->setDefinition('deprecated_foo', $definition);
$builder->compile();
$builder->get('deprecated_foo');
}

public function testRegister()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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\Reference;
Expand Down Expand Up @@ -558,23 +557,17 @@ public function testAutowire()

/**
* @group legacy
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* @expectedDeprecation Using the attribute "class" is deprecated for the service "bar" which is defined as an alias %s.
* @expectedDeprecation Using the element "tag" is deprecated for the service "bar" which is defined as an alias %s.
* @expectedDeprecation Using the element "factory" is deprecated for the service "bar" which is defined as an alias %s.
*/
public function testAliasDefinitionContainsUnsupportedElements()
{
$deprecations = array(
'Using the attribute "class" is deprecated for the service "bar" which is defined as an alias',
'Using the element "tag" is deprecated for the service "bar" which is defined as an alias',
'Using the element "factory" is deprecated for the service "bar" which is defined as an alias',
);

ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () {
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));

$loader->load('legacy_invalid_alias_definition.xml');
$loader->load('legacy_invalid_alias_definition.xml');

$this->assertTrue($container->has('bar'));
});
$this->assertTrue($container->has('bar'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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;
Expand All @@ -28,16 +27,14 @@ public function testRenderFallbackToInlineStrategyIfEsiNotSupported()

/**
* @group legacy
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* @expectedDeprecation Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated %s.
*/
public function testRenderFallbackWithObjectAttributesIsDeprecated()
{
ErrorAssert::assertDeprecationsAreTriggered('Passing non-scalar values 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);
});
$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);
}

public function testRender()
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/Yaml/Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Yaml\Tests;

use Symfony\Bridge\PhpUnit\ErrorAssert;
use Symfony\Component\Yaml\Inline;
use Symfony\Component\Yaml\Yaml;

Expand Down Expand Up @@ -255,14 +254,12 @@ public function getScalarIndicators()

/**
* @group legacy
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
*/
public function testParseUnquotedScalarStartingWithPercentCharacter()
{
ErrorAssert::assertDeprecationsAreTriggered('Not quoting the scalar "%foo " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () {
Inline::parse('{ foo: %foo }');
});
Inline::parse('{ foo: %bar }');
}

/**
Expand Down
0