Skip to content

Commit 13a16b1

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents ee64c66 + 066402a commit 13a16b1

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

Tests/ExpressionLanguageTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212
namespace Symfony\Component\ExpressionLanguage\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Cache\CacheItemInterface;
16+
use Psr\Cache\CacheItemPoolInterface;
1517
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
1618
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1719
use Symfony\Component\ExpressionLanguage\ParsedExpression;
20+
use Symfony\Component\ExpressionLanguage\SyntaxError;
1821
use Symfony\Component\ExpressionLanguage\Tests\Fixtures\TestProvider;
1922

2023
class ExpressionLanguageTest extends TestCase
2124
{
2225
public function testCachedParse()
2326
{
24-
$cacheMock = $this->getMockBuilder(\Psr\Cache\CacheItemPoolInterface::class)->getMock();
25-
$cacheItemMock = $this->getMockBuilder(\Psr\Cache\CacheItemInterface::class)->getMock();
27+
$cacheMock = $this->createMock(CacheItemPoolInterface::class);
28+
$cacheItemMock = $this->createMock(CacheItemInterface::class);
2629
$savedParsedExpression = null;
2730
$expressionLanguage = new ExpressionLanguage($cacheMock);
2831

@@ -107,7 +110,7 @@ public function testShortCircuitOperatorsCompile($expression, array $names, $exp
107110

108111
public function testParseThrowsInsteadOfNotice()
109112
{
110-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
113+
$this->expectException(SyntaxError::class);
111114
$this->expectExceptionMessage('Unexpected end of expression around position 6 for expression `node.`.');
112115
$expressionLanguage = new ExpressionLanguage();
113116
$expressionLanguage->parse('node.', ['node']);
@@ -155,8 +158,8 @@ public function testStrictEquality()
155158

156159
public function testCachingWithDifferentNamesOrder()
157160
{
158-
$cacheMock = $this->getMockBuilder(\Psr\Cache\CacheItemPoolInterface::class)->getMock();
159-
$cacheItemMock = $this->getMockBuilder(\Psr\Cache\CacheItemInterface::class)->getMock();
161+
$cacheMock = $this->createMock(CacheItemPoolInterface::class);
162+
$cacheItemMock = $this->createMock(CacheItemInterface::class);
160163
$expressionLanguage = new ExpressionLanguage($cacheMock);
161164
$savedParsedExpression = null;
162165

Tests/LexerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\ExpressionLanguage\Lexer;
16+
use Symfony\Component\ExpressionLanguage\SyntaxError;
1617
use Symfony\Component\ExpressionLanguage\Token;
1718
use Symfony\Component\ExpressionLanguage\TokenStream;
1819

@@ -39,15 +40,15 @@ public function testTokenize($tokens, $expression)
3940

4041
public function testTokenizeThrowsErrorWithMessage()
4142
{
42-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
43+
$this->expectException(SyntaxError::class);
4344
$this->expectExceptionMessage('Unexpected character "\'" around position 33 for expression `service(faulty.expression.example\').dummyMethod()`.');
4445
$expression = "service(faulty.expression.example').dummyMethod()";
4546
$this->lexer->tokenize($expression);
4647
}
4748

4849
public function testTokenizeThrowsErrorOnUnclosedBrace()
4950
{
50-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
51+
$this->expectException(SyntaxError::class);
5152
$this->expectExceptionMessage('Unclosed "(" around position 7 for expression `service(unclosed.expression.dummyMethod()`.');
5253
$expression = 'service(unclosed.expression.dummyMethod()';
5354
$this->lexer->tokenize($expression);

Tests/ParserTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ParserTest extends TestCase
2121
{
2222
public function testParseWithInvalidName()
2323
{
24-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
24+
$this->expectException(SyntaxError::class);
2525
$this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.');
2626
$lexer = new Lexer();
2727
$parser = new Parser([]);
@@ -30,7 +30,7 @@ public function testParseWithInvalidName()
3030

3131
public function testParseWithZeroInNames()
3232
{
33-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
33+
$this->expectException(SyntaxError::class);
3434
$this->expectExceptionMessage('Variable "foo" is not valid around position 1 for expression `foo`.');
3535
$lexer = new Lexer();
3636
$parser = new Parser([]);
@@ -198,7 +198,7 @@ private function createGetAttrNode($node, $item, $type)
198198
*/
199199
public function testParseWithInvalidPostfixData($expr, $names = [])
200200
{
201-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
201+
$this->expectException(SyntaxError::class);
202202
$lexer = new Lexer();
203203
$parser = new Parser([]);
204204
$parser->parse($lexer->tokenize($expr), $names);
@@ -228,7 +228,7 @@ public function getInvalidPostfixData()
228228

229229
public function testNameProposal()
230230
{
231-
$this->expectException(\Symfony\Component\ExpressionLanguage\SyntaxError::class);
231+
$this->expectException(SyntaxError::class);
232232
$this->expectExceptionMessage('Did you mean "baz"?');
233233
$lexer = new Lexer();
234234
$parser = new Parser([]);

0 commit comments

Comments
 (0)