@@ -17,35 +17,33 @@ public function setUp()
1717 $ this ->connection (),
1818 $ this ->connection (true ),
1919 );
20- $ this ->transaction = new \PHPixie \ORM \Plans \Transaction ;
20+ $ this ->transaction = new \PHPixie \ORM \Plans \Transaction ( $ this -> connections ) ;
2121 }
2222
2323 protected function connection ($ transactable = false )
2424 {
25- $ class = $ transactable ? '\PHPixie\Database\Connection\Transactable ' : '\PHPixie\Database\Connection ' ;
26- return $ this ->abstractMock ($ class , array (
27- 'beginTransaction ' ,
28- 'commitTransaction ' ,
29- 'rollbackTransaction ' ,
30- ));
25+ $ class = $ transactable ? '\PHPixie\Database\Driver\PDO\Connection ' : '\PHPixie\Database\Connection ' ;
26+ return $ this ->quickMock ($ class );
3127 }
3228
3329 /**
3430 * @covers ::begin
35- * @covers ::<protected>
36- */
37- public function testBeginTransaction ()
38- {
39- $ this ->transactionTest ('begin ' );
40- }
41-
42- /**
4331 * @covers ::commit
4432 * @covers ::<protected>
4533 */
46- public function testCommitTransaction ()
34+ public function testTransaction ()
4735 {
48- $ this ->transactionTest ('commit ' );
36+ $ this ->method ($ this ->connections [0 ], 'inTransaction ' , false , array (), 0 );
37+ $ this ->method ($ this ->connections [2 ], 'inTransaction ' , false , array (), 0 );
38+
39+ $ this ->method ($ this ->connections [0 ], 'beginTransaction ' , null , array (), 1 );
40+ $ this ->method ($ this ->connections [2 ], 'beginTransaction ' , null , array (), 1 );
41+
42+ $ this ->method ($ this ->connections [0 ], 'commitTransaction ' , null , array (), 2 );
43+ $ this ->method ($ this ->connections [2 ], 'commitTransaction ' , null , array (), 2 );
44+
45+ $ this ->transaction ->begin ();
46+ $ this ->transaction ->commit ();
4947 }
5048
5149 /**
@@ -54,17 +52,16 @@ public function testCommitTransaction()
5452 */
5553 public function testRollbackTransaction ()
5654 {
57- $ this ->transactionTest ('rollback ' );
58- }
59-
60- protected function transactionTest ($ method )
61- {
62- $ connectionMethod = $ method .'Transaction ' ;
63- $ this ->method ($ this ->connections [0 ], $ connectionMethod , null , array (), 0 );
64- $ this ->connections [1 ]
65- ->expects ($ this ->never ())
66- ->method ($ connectionMethod );
67- $ this ->method ($ this ->connections [2 ], $ connectionMethod , null , array (), 0 );
68- $ this ->transaction ->$ method ($ this ->connections );
55+ $ this ->method ($ this ->connections [0 ], 'inTransaction ' , false , array (), 0 );
56+ $ this ->method ($ this ->connections [2 ], 'inTransaction ' , false , array (), 0 );
57+
58+ $ this ->method ($ this ->connections [0 ], 'beginTransaction ' , null , array (), 1 );
59+ $ this ->method ($ this ->connections [2 ], 'beginTransaction ' , null , array (), 1 );
60+
61+ $ this ->method ($ this ->connections [0 ], 'rollbackTransaction ' , null , array (), 2 );
62+ $ this ->method ($ this ->connections [2 ], 'rollbackTransaction ' , null , array (), 2 );
63+
64+ $ this ->transaction ->begin ();
65+ $ this ->transaction ->rollback ();
6966 }
7067}
0 commit comments