Update to PhpUnitBridge and fix deprecations

This commit is contained in:
Jérémy Derussé
2019-08-07 16:35:43 +02:00
parent 9270385cd2
commit b776e41f5a
20 changed files with 152 additions and 189 deletions
+34 -41
View File
@@ -22,11 +22,12 @@ use Twig\Source;
class ExpressionParserTest extends \PHPUnit\Framework\TestCase
{
/**
* @expectedException \Twig\Error\SyntaxError
* @dataProvider getFailingTestsForAssignment
*/
public function testCanOnlyAssignToNames($template)
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
@@ -65,11 +66,12 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
}
/**
* @expectedException \Twig\Error\SyntaxError
* @dataProvider getFailingTestsForArray
*/
public function testArraySyntaxError($template)
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
@@ -160,11 +162,10 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
];
}
/**
* @expectedException \Twig\Error\SyntaxError
*/
public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings()
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
$stream = $env->tokenize(new Source('{{ "a" "b" }}', 'index'));
$parser = new Parser($env);
@@ -232,34 +233,31 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
];
}
/**
* @expectedException \Twig\Error\SyntaxError
*/
public function testAttributeCallDoesNotSupportNamedArguments()
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ foo.bar(name="Foo") }}', 'index')));
}
/**
* @expectedException \Twig\Error\SyntaxError
*/
public function testMacroCallDoesNotSupportNamedArguments()
{
$this->expectException('\Twig\Error\SyntaxError');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index')));
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.
*/
public function testMacroDefinitionDoesNotSupportNonNameVariableName()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
@@ -267,12 +265,13 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage A default value for an argument must be a constant (a boolean, a string, a number, or an array) in "index" at line 1
* @dataProvider getMacroDefinitionDoesNotSupportNonConstantDefaultValues
*/
public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template)
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('A default value for an argument must be a constant (a boolean, a string, a number, or an array) in "index" at line 1');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
@@ -315,72 +314,66 @@ class ExpressionParserTest extends \PHPUnit\Framework\TestCase
];
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?
*/
public function testUnknownFunction()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ cycl() }}', 'index')));
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage Unknown "foobar" function in "index" at line 1.
*/
public function testUnknownFunctionWithoutSuggestions()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "foobar" function in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ foobar() }}', 'index')));
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?
*/
public function testUnknownFilter()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ 1|lowe }}', 'index')));
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage Unknown "foobar" filter in "index" at line 1.
*/
public function testUnknownFilterWithoutSuggestions()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "foobar" filter in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$parser->parse($env->tokenize(new Source('{{ 1|foobar }}', 'index')));
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage Unknown "nul" test. Did you mean "null" in "index" at line 1
*/
public function testUnknownTest()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "nul" test. Did you mean "null" in "index" at line 1');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);
$stream = $env->tokenize(new Source('{{ 1 is nul }}', 'index'));
$parser->parse($stream);
}
/**
* @expectedException \Twig\Error\SyntaxError
* @expectedExceptionMessage Unknown "foobar" test in "index" at line 1.
*/
public function testUnknownTestWithoutSuggestions()
{
$this->expectException('\Twig\Error\SyntaxError');
$this->expectExceptionMessage('Unknown "foobar" test in "index" at line 1.');
$env = new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock(), ['cache' => false, 'autoescape' => false]);
$parser = new Parser($env);