File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bavix \Wallet \Test ;
4+
5+ use Bavix \Wallet \Services \WalletService ;
6+ use Bavix \Wallet \Test \Common \Models \Wallet ;
7+ use Bavix \Wallet \Test \Models \UserConfirm ;
8+
9+ class ConfirmMockTest extends TestCase
10+ {
11+
12+ /**
13+ * @return void
14+ */
15+ public function testFailConfirm (): void
16+ {
17+ /**
18+ * @var UserConfirm $userConfirm
19+ */
20+ $ userConfirm = factory (UserConfirm::class)->create ();
21+ $ transaction = $ userConfirm ->deposit (100 , null , false );
22+ $ this ->assertEquals ($ userConfirm ->wallet ->id , $ transaction ->wallet ->id );
23+ $ this ->assertEquals ($ userConfirm ->id , $ transaction ->payable_id );
24+ $ this ->assertInstanceOf (UserConfirm::class, $ transaction ->payable );
25+ $ this ->assertFalse ($ transaction ->confirmed );
26+
27+ $ wallet = app (WalletService::class)
28+ ->getWallet ($ userConfirm );
29+
30+ $ mockWallet = $ this ->createMock (\get_class ($ wallet ));
31+ $ mockWallet ->method ('refreshBalance ' )
32+ ->willReturn (false );
33+
34+ /**
35+ * @var Wallet $mockWallet
36+ */
37+ $ this ->assertInstanceOf (Wallet::class, $ wallet );
38+ $ this ->assertFalse ($ mockWallet ->refreshBalance ());
39+
40+ $ userConfirm ->setRelation ('wallet ' , $ mockWallet );
41+ $ this ->assertFalse ($ userConfirm ->confirm ($ transaction ));
42+ }
43+
44+ }
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ public function testUserConfirm(): void
137137 $ this ->assertInstanceOf (UserConfirm::class, $ transaction ->payable );
138138 $ this ->assertFalse ($ transaction ->confirmed );
139139
140- $ userConfirm ->confirm ($ transaction );
140+ $ this -> assertTrue ( $ userConfirm ->confirm ($ transaction) );
141141 $ this ->assertTrue ($ transaction ->confirmed );
142142 }
143143
You can’t perform that action at this time.
0 commit comments