5
5
namespace Doctrine \Migrations \Tests \Tools ;
6
6
7
7
use Doctrine \DBAL \Connection ;
8
- use Doctrine \Deprecations \PHPUnit \VerifyDeprecations ;
9
8
use Doctrine \Migrations \Tools \TransactionHelper ;
9
+ use LogicException ;
10
10
use PDO ;
11
11
use PHPUnit \Framework \TestCase ;
12
12
13
13
final class TransactionHelperTest extends TestCase
14
14
{
15
- use VerifyDeprecations;
16
-
17
- public function testItTriggersADeprecationWhenUseful (): void
15
+ public function testItThrowsAnExceptionWhenAttemptingToCommitWhileNotInsideATransaction (): void
18
16
{
19
17
$ connection = $ this ->createStub (Connection::class);
20
18
$ wrappedConnection = $ this ->createStub (PDO ::class);
@@ -23,18 +21,27 @@ public function testItTriggersADeprecationWhenUseful(): void
23
21
24
22
$ wrappedConnection ->method ('inTransaction ' )->willReturn (false );
25
23
26
- $ this ->expectDeprecationWithIdentifier (
27
- 'https://github.com/doctrine/migrations/issues/1169 '
28
- );
24
+ $ this ->expectException (LogicException::class);
29
25
TransactionHelper::commitIfInTransaction ($ connection );
26
+ }
27
+
28
+ public function testItThrowsAnExceptionWhenAttemptingToRollbackWhileNotInsideATransaction (): void
29
+ {
30
+ $ connection = $ this ->createStub (Connection::class);
31
+ $ wrappedConnection = $ this ->createStub (PDO ::class);
30
32
31
- $ this ->expectDeprecationWithIdentifier (
32
- 'https://github.com/doctrine/migrations/issues/1169 '
33
- );
33
+ $ connection ->method ('getNativeConnection ' )->willReturn ($ wrappedConnection );
34
+
35
+ $ wrappedConnection ->method ('inTransaction ' )->willReturn (false );
36
+
37
+ $ this ->expectException (LogicException::class);
34
38
TransactionHelper::rollbackIfInTransaction ($ connection );
35
39
}
36
40
37
- public function testItDoesNotTriggerADeprecationWhenUseless (): void
41
+ /**
42
+ * @doesNotPerformAssertions
43
+ */
44
+ public function testItDoesNotThrowAnExceptionWhenUseless (): void
38
45
{
39
46
$ connection = $ this ->createStub (Connection::class);
40
47
$ wrappedConnection = $ this ->createStub (PDO ::class);
@@ -43,14 +50,7 @@ public function testItDoesNotTriggerADeprecationWhenUseless(): void
43
50
44
51
$ wrappedConnection ->method ('inTransaction ' )->willReturn (true );
45
52
46
- $ this ->expectNoDeprecationWithIdentifier (
47
- 'https://github.com/doctrine/migrations/issues/1169 '
48
- );
49
53
TransactionHelper::commitIfInTransaction ($ connection );
50
-
51
- $ this ->expectNoDeprecationWithIdentifier (
52
- 'https://github.com/doctrine/migrations/issues/1169 '
53
- );
54
54
TransactionHelper::rollbackIfInTransaction ($ connection );
55
55
}
56
56
}
0 commit comments