forked from changeweb/Unifiedtransform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaymentModuleTest.php
More file actions
executable file
·70 lines (66 loc) · 1.88 KB
/
Copy pathPaymentModuleTest.php
File metadata and controls
executable file
·70 lines (66 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Tests\Feature;
use App\User;
use Stripe\Stripe;
use Stripe\Token;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class PaymentModuleTest extends TestCase
{
use RefreshDatabase;
public function setUp(): void {
parent::setUp();
$student = factory(User::class)->states('student')->create();
$this->actingAs($student);
$this->withoutExceptionHandling();
Stripe::setApiKey(env('STRIPE_KEY'));
}
/**
* @test
* @return void
*/
public function student_can_view_payment_page()
{
$this->get('stripe/charge')
->assertStatus(200)
->assertViewIs('stripe.payment')
->assertViewHas('fees_fields');
}
/**
* @test
* @return void
*/
// Uncomment after setting Stripe key in .env file
// public function student_can_pay_amount(){
// $stripe_token = Token::create([
// 'card' => [
// 'number' => '4242424242424242',
// 'exp_month' => 5,
// 'exp_year' => date('Y', strtotime('+1 year')),
// 'cvc' => '314'
// ]
// ]);
// $amount = 10.50;
// $request = [
// 'stripeToken' => $stripe_token->id,
// 'amount' => $amount,
// 'charge_field' => 'Exam Fee',
// ];
// $this->followingRedirects()->post('stripe/charge', $request)
// ->assertStatus(200);
// $this->assertDatabaseHas('payments',[
// 'amount' => $amount,
// ]);
// }
/**
* @test
* @return void
*/
public function student_can_view_receipts_page(){
$this->get('stripe/receipts')
->assertStatus(200)
->assertViewIs('stripe.receipts')
->assertViewHas('receipts');
}
}