Skip to content

Commit 1625cc3

Browse files
committed
Fix deprecated phpunit annotation
1 parent 4a93149 commit 1625cc3

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

Tests/LockTest.php

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

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Log\LoggerInterface;
16+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1617
use Symfony\Component\Lock\Exception\LockConflictedException;
1718
use Symfony\Component\Lock\Key;
1819
use Symfony\Component\Lock\Lock;
@@ -23,6 +24,8 @@
2324
*/
2425
class LockTest extends TestCase
2526
{
27+
use ForwardCompatTestTrait;
28+
2629
public function testAcquireNoBlocking()
2730
{
2831
$key = new Key(uniqid(__METHOD__, true));
@@ -170,11 +173,9 @@ public function testNoAutoReleaseWhenNotConfigured()
170173
unset($lock);
171174
}
172175

173-
/**
174-
* @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
175-
*/
176176
public function testReleaseThrowsExceptionIfNotWellDeleted()
177177
{
178+
$this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
178179
$key = new Key(uniqid(__METHOD__, true));
179180
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
180181
$lock = new Lock($key, $store, 10);
@@ -193,11 +194,9 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
193194
$lock->release();
194195
}
195196

196-
/**
197-
* @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
198-
*/
199197
public function testReleaseThrowsAndLog()
200198
{
199+
$this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
201200
$key = new Key(uniqid(__METHOD__, true));
202201
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
203202
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();

Tests/Store/CombinedStoreTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ private function doSetUp()
6969
$this->store = new CombinedStore([$this->store1, $this->store2], $this->strategy);
7070
}
7171

72-
/**
73-
* @expectedException \Symfony\Component\Lock\Exception\LockConflictedException
74-
*/
7572
public function testSaveThrowsExceptionOnFailure()
7673
{
74+
$this->expectException('Symfony\Component\Lock\Exception\LockConflictedException');
7775
$key = new Key(uniqid(__METHOD__, true));
7876

7977
$this->store1
@@ -166,11 +164,9 @@ public function testSaveAbortWhenStrategyCantBeMet()
166164
}
167165
}
168166

169-
/**
170-
* @expectedException \Symfony\Component\Lock\Exception\LockConflictedException
171-
*/
172167
public function testputOffExpirationThrowsExceptionOnFailure()
173168
{
169+
$this->expectException('Symfony\Component\Lock\Exception\LockConflictedException');
174170
$key = new Key(uniqid(__METHOD__, true));
175171
$ttl = random_int(1, 10);
176172

Tests/Store/ExpiringStoreTestTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Component\Lock\Exception\LockExpiredException;
1516
use Symfony\Component\Lock\Key;
1617
use Symfony\Component\Lock\StoreInterface;
@@ -20,6 +21,8 @@
2021
*/
2122
trait ExpiringStoreTestTrait
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
/**
2427
* Amount of microseconds used as a delay to test expiration. Should be
2528
* small enough not to slow the test suite too much, and high enough not to
@@ -57,11 +60,10 @@ public function testExpiration()
5760

5861
/**
5962
* Tests the store thrown exception when TTL expires.
60-
*
61-
* @expectedException \Symfony\Component\Lock\Exception\LockExpiredException
6263
*/
6364
public function testAbortAfterExpiration()
6465
{
66+
$this->expectException('\Symfony\Component\Lock\Exception\LockExpiredException');
6567
$key = new Key(uniqid(__METHOD__, true));
6668

6769
/** @var StoreInterface $store */

Tests/Store/FlockStoreTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Component\Lock\Key;
1516
use Symfony\Component\Lock\Store\FlockStore;
1617

@@ -19,6 +20,7 @@
1920
*/
2021
class FlockStoreTest extends AbstractStoreTest
2122
{
23+
use ForwardCompatTestTrait;
2224
use BlockingStoreTestTrait;
2325

2426
/**
@@ -29,25 +31,21 @@ protected function getStore()
2931
return new FlockStore();
3032
}
3133

32-
/**
33-
* @expectedException \Symfony\Component\Lock\Exception\InvalidArgumentException
34-
* @expectedExceptionMessage The directory "/a/b/c/d/e" is not writable.
35-
*/
3634
public function testConstructWhenRepositoryDoesNotExist()
3735
{
36+
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
37+
$this->expectExceptionMessage('The directory "/a/b/c/d/e" is not writable.');
3838
if (!getenv('USER') || 'root' === getenv('USER')) {
3939
$this->markTestSkipped('This test will fail if run under superuser');
4040
}
4141

4242
new FlockStore('/a/b/c/d/e');
4343
}
4444

45-
/**
46-
* @expectedException \Symfony\Component\Lock\Exception\InvalidArgumentException
47-
* @expectedExceptionMessage The directory "/" is not writable.
48-
*/
4945
public function testConstructWhenRepositoryIsNotWriteable()
5046
{
47+
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
48+
$this->expectExceptionMessage('The directory "/" is not writable.');
5149
if (!getenv('USER') || 'root' === getenv('USER')) {
5250
$this->markTestSkipped('This test will fail if run under superuser');
5351
}

0 commit comments

Comments
 (0)