Completed
Push — master ( 84f951...e4e2cf )
by
unknown
10s
created

testChargeUserWithStripe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 23
rs 9.0856
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Srtipe\Tests\Unit;
4
5
use App\Containers\Payment\Tasks\AssignPaymentAccountToUserTask;
6
use App\Containers\Payment\Traits\MockablePaymentsTrait;
7
use App\Containers\Stripe\Models\StripeAccount;
8
use App\Containers\User\Tests\TestCase;
9
use Illuminate\Support\Facades\App;
10
11
/**
12
 * Class ChargeUserWithStripeTest
13
 *
14
 * @author  Mahmoud Zalt  <[email protected]>
15
 */
16
class ChargeUserWithStripeTest extends TestCase
17
{
18
19
    use MockablePaymentsTrait;
20
21
    public function testChargeUserWithStripe()
22
    {
23
        // Mock the payments
24
        $this->mockPayments();
25
26
        // create testing user
27
        $user = $this->getTestingUser();
28
29
        $stripeAccount = factory(StripeAccount::class)->create([
30
            'customer_id' => 'cus_8mBD5S1SoyD4zL',
31
        ]);
32
33
        App::make(AssignPaymentAccountToUserTask::class)->run($stripeAccount, $user, 'nickname');
34
35
        $amount = 100;
36
37
        // Start the test:
38
        $account = $user->paymentAccounts->first();
39
40
        $stripeResponse = $user->charge($account, $amount);
41
42
        $this->assertEquals($stripeResponse['payment_method'], 'stripe');
43
    }
44
}
45