Skip to content

Commit 5db9d17

Browse files
Merge branch '3.4' into 4.3
* 3.4: Fix tests Fix deprecated phpunit annotation
2 parents 51d0d55 + ac3f20c commit 5db9d17

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

Tests/LockTest.php

Lines changed: 6 additions & 9 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));
@@ -184,11 +187,9 @@ public function testNoAutoReleaseWhenNotConfigured()
184187
unset($lock);
185188
}
186189

187-
/**
188-
* @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
189-
*/
190190
public function testReleaseThrowsExceptionWhenDeletionFail()
191191
{
192+
$this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
192193
$key = new Key(uniqid(__METHOD__, true));
193194
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
194195
$lock = new Lock($key, $store, 10);
@@ -207,11 +208,9 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
207208
$lock->release();
208209
}
209210

210-
/**
211-
* @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
212-
*/
213211
public function testReleaseThrowsExceptionIfNotWellDeleted()
214212
{
213+
$this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
215214
$key = new Key(uniqid(__METHOD__, true));
216215
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
217216
$lock = new Lock($key, $store, 10);
@@ -230,11 +229,9 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
230229
$lock->release();
231230
}
232231

233-
/**
234-
* @expectedException \Symfony\Component\Lock\Exception\LockReleasingException
235-
*/
236232
public function testReleaseThrowsAndLog()
237233
{
234+
$this->expectException('Symfony\Component\Lock\Exception\LockReleasingException');
238235
$key = new Key(uniqid(__METHOD__, true));
239236
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
240237
$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: 2 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;
@@ -57,11 +58,10 @@ public function testExpiration()
5758

5859
/**
5960
* Tests the store thrown exception when TTL expires.
60-
*
61-
* @expectedException \Symfony\Component\Lock\Exception\LockExpiredException
6261
*/
6362
public function testAbortAfterExpiration()
6463
{
64+
$this->expectException('\Symfony\Component\Lock\Exception\LockExpiredException');
6565
$key = new Key(uniqid(__METHOD__, true));
6666

6767
/** @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)