@@ -43,34 +43,26 @@ protected function setUp(): void
43
43
44
44
public function testDecoratorWrapsInTransactionAndFlushes ()
45
45
{
46
- $ this ->connection ->expects ($ this ->once ())
47
- ->method ('beginTransaction ' )
48
- ;
49
- $ this ->connection ->expects ($ this ->once ())
50
- ->method ('commit ' )
51
- ;
52
- $ this ->entityManager ->expects ($ this ->once ())
53
- ->method ('flush ' )
54
- ;
55
-
56
46
$ handler = new TestHandler ();
47
+
48
+ $ this ->connection ->expects ($ this ->once ())->method ('beginTransaction ' );
49
+ $ this ->connection ->expects ($ this ->once ())->method ('commit ' );
50
+ $ this ->entityManager ->expects ($ this ->once ())->method ('flush ' );
51
+
57
52
$ result = $ this ->decorator ->call ($ handler ->handle (...));
58
53
$ this ->assertSame ('success ' , $ result );
59
54
}
60
55
61
56
public function testTransactionIsRolledBackOnException ()
62
57
{
63
- $ this ->connection ->expects ($ this ->once ())
64
- ->method ('beginTransaction ' )
65
- ;
66
- $ this ->connection ->expects ($ this ->once ())
67
- ->method ('rollBack ' )
68
- ;
58
+ $ this ->connection ->expects ($ this ->once ())->method ('beginTransaction ' );
59
+ $ this ->connection ->expects ($ this ->once ())->method ('rollBack ' );
60
+
61
+ $ handler = new TestHandler ();
69
62
70
63
$ this ->expectException (\RuntimeException::class);
71
64
$ this ->expectExceptionMessage ('A runtime error. ' );
72
65
73
- $ handler = new TestHandler ();
74
66
$ this ->decorator ->call ($ handler ->handleWithError (...));
75
67
}
76
68
@@ -79,11 +71,12 @@ public function testInvalidEntityManagerThrowsException()
79
71
$ this ->managerRegistry
80
72
->method ('getManager ' )
81
73
->with ('unknown_manager ' )
82
- ->will ($ this ->throwException (new \InvalidArgumentException ()));
74
+ ->willThrowException (new \InvalidArgumentException ());
75
+
76
+ $ handler = new TestHandler ();
83
77
84
78
$ this ->expectException (\InvalidArgumentException::class);
85
79
86
- $ handler = new TestHandler ();
87
80
$ this ->decorator ->call ($ handler ->handleWithUnknownManager (...));
88
81
}
89
82
}
0 commit comments