minor #19066 [2.8] update tests to use the new error assertion helper (xabbuh)
This PR was merged into the 2.8 branch.
Discussion
----------
[2.8] update tests to use the new error assertion helper
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
e5cf4d4
update tests to use the new error assertion helper
This commit is contained in:
commit
f8937bd8b8
@ -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;
|
||||
@ -61,27 +62,13 @@ 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->createService($definition, '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\Yaml\Tests;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ErrorAssert;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
@ -930,27 +931,14 @@ EOF;
|
||||
*/
|
||||
public function testColonInMappingValueException()
|
||||
{
|
||||
$parser = $this->parser;
|
||||
|
||||
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) {
|
||||
$yaml = <<<EOF
|
||||
foo: bar: baz
|
||||
EOF;
|
||||
|
||||
$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;
|
||||
$parser->parse($yaml);
|
||||
});
|
||||
|
||||
$this->parser->parse($yaml);
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertCount(1, $deprecations);
|
||||
$this->assertContains('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.', $deprecations[0]);
|
||||
}
|
||||
|
||||
public function testColonInMappingValueExceptionNotTriggeredByColonInComment()
|
||||
|
Reference in New Issue
Block a user