1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\Feature\Api; |
4
|
|
|
|
5
|
|
|
use App\Models\Transaction; |
6
|
|
|
use Tests\Features\TestCase; |
7
|
|
|
|
8
|
|
|
class TransactionController extends TestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* A basic test example. |
12
|
|
|
* @test |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
public function it_can_get_all_transactions() |
16
|
|
|
{ |
17
|
|
|
// Arrange |
18
|
|
|
$url = '/api/v1/transactions'; |
19
|
|
|
$transaction = factory(Transaction::class)->create(); |
20
|
|
|
|
21
|
|
|
// Act |
22
|
|
|
$response = $this->get($url); |
23
|
|
|
|
24
|
|
|
// Assert |
25
|
|
|
$response->assertStatus(200) |
26
|
|
|
->assertJsonFragment([ |
27
|
|
|
'id' => $transaction->id, |
28
|
|
|
'status' => [ |
29
|
|
|
'id' => $transaction->status->id, |
30
|
|
|
'name' => $transaction->status->name, |
31
|
|
|
'slug' => $transaction->status->slug |
32
|
|
|
], |
33
|
|
|
'type' => [ |
34
|
|
|
'id' => $transaction->type->id, |
35
|
|
|
'name' => $transaction->type->name, |
36
|
|
|
'slug' => $transaction->type->slug |
37
|
|
|
], |
38
|
|
|
'account_name' => $transaction->account_name, |
39
|
|
|
'to_account_name' => $transaction->to_account_name, |
40
|
|
|
'payee_name' => $transaction->payee_name, |
41
|
|
|
'category_name' => $transaction->category_name, |
42
|
|
|
'sub_category_name' => $transaction->sub_category_name, |
43
|
|
|
'amount' => round($transaction->amount, 2), |
44
|
|
|
'notes' => $transaction->notes, |
45
|
|
|
'created_at' => $transaction->created_at->toIso8601String(), |
46
|
|
|
'updated_at' => $transaction->updated_at->toIso8601String() |
47
|
|
|
]); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|