Skip to content

Commit 7cd0095

Browse files
committed
Replace calls to setExpectedException by Pollyfill
1 parent f7e3337 commit 7cd0095

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Tests/ParserCache/ParserCacheAdapterTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\ExpressionLanguage\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\ExpressionLanguage\Node\Node;
1617
use Symfony\Component\ExpressionLanguage\ParsedExpression;
1718
use Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheAdapter;
@@ -21,6 +22,8 @@
2122
*/
2223
class ParserCacheAdapterTest extends TestCase
2324
{
25+
use ForwardCompatTestTrait;
26+
2427
public function testGetItem()
2528
{
2629
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
@@ -75,7 +78,7 @@ public function testGetItems()
7578
{
7679
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
7780
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
78-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
81+
$this->expectException(\BadMethodCallException::class);
7982

8083
$parserCacheAdapter->getItems();
8184
}
@@ -85,7 +88,7 @@ public function testHasItem()
8588
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
8689
$key = 'key';
8790
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
88-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
91+
$this->expectException(\BadMethodCallException::class);
8992

9093
$parserCacheAdapter->hasItem($key);
9194
}
@@ -94,7 +97,7 @@ public function testClear()
9497
{
9598
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
9699
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
97-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
100+
$this->expectException(\BadMethodCallException::class);
98101

99102
$parserCacheAdapter->clear();
100103
}
@@ -104,7 +107,7 @@ public function testDeleteItem()
104107
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
105108
$key = 'key';
106109
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
107-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
110+
$this->expectException(\BadMethodCallException::class);
108111

109112
$parserCacheAdapter->deleteItem($key);
110113
}
@@ -114,7 +117,7 @@ public function testDeleteItems()
114117
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
115118
$keys = ['key'];
116119
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
117-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
120+
$this->expectException(\BadMethodCallException::class);
118121

119122
$parserCacheAdapter->deleteItems($keys);
120123
}
@@ -124,7 +127,7 @@ public function testSaveDeferred()
124127
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
125128
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
126129
$cacheItemMock = $this->getMockBuilder('Psr\Cache\CacheItemInterface')->getMock();
127-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
130+
$this->expectException(\BadMethodCallException::class);
128131

129132
$parserCacheAdapter->saveDeferred($cacheItemMock);
130133
}
@@ -133,7 +136,7 @@ public function testCommit()
133136
{
134137
$poolMock = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ParserCache\ParserCacheInterface')->getMock();
135138
$parserCacheAdapter = new ParserCacheAdapter($poolMock);
136-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}(\BadMethodCallException::class);
139+
$this->expectException(\BadMethodCallException::class);
137140

138141
$parserCacheAdapter->commit();
139142
}

0 commit comments

Comments
 (0)