GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — rewrite-laravel ( 622436...e336b9 )
by Oliver
03:08
created

TransactionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 82
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testDeleteTransactions() 0 13 1
B testDownloadTransactions() 0 31 1
A testDownloadAttachment() 0 20 1
A addReceiptsToTransaction() 0 6 1
1
<?php
2
/**
3
 * MmexControllerTest.php, laravel-money-manager-ex.
4
 *
5
 * This File belongs to to Project laravel-money-manager-ex
6
 *
7
 * @author Oliver Kaufmann <[email protected]>
8
 *
9
 * @version 1.0
10
 */
11
12
namespace Tests\Feature\MmexClient;
13
14
use App\Models\Transaction;
15
16
class TransactionTest extends MmexTestCase
17
{
18
    public function testDeleteTransactions()
19
    {
20
        // Arrange
21
        $transaction = factory(Transaction::class)->create();
22
        $url = $this->buildUrl('', ['delete_group' => $transaction->id]);
23
24
        // Act
25
        $response = $this->get($url);
26
27
        // Assert
28
        $this->seeSuccess($response);
29
        $this->seeIsSoftDeletedInDatabase('transactions', ['payee_name' => $transaction->payee_name]); // must not be deleted! just soft deleted.
30
    }
31
32
    public function testDownloadTransactions()
33
    {
34
        // Arrange
35
        /** @var Transaction $transaction */
36
        $transaction = factory(Transaction::class)->create();
37
        $this->addReceiptsToTransaction($transaction);
38
        $url = $this->buildUrl('', ['download_transaction' => 'true']);
39
40
        // Act
41
        $response = $this->get($url);
42
43
        // Assert
44
        $response->assertStatus(200)
45
            ->assertJsonFragment(
46
                [
47
                    'ID'          => $transaction->id,
48
                    'Date'        => $transaction->date,
49
                    'Account'     => $transaction->account_name,
50
                    'ToAccount'   => $transaction->to_account_name,
51
                    'Status'      => $transaction->status->slug,
52
                    'Type'        => $transaction->type->name,
53
                    'Payee'       => $transaction->payee_name,
54
                    'Category'    => $transaction->category_name,
55
                    'SubCategory' => $transaction->sub_category_name,
56
                    'Amount'      => (string)$transaction->amount,
57
                    'Notes'       => $transaction->notes,
58
                    'Attachments' => 'Transaction_'.$transaction->id.'_test-receipt.png;Transaction_'.$transaction->id
59
                        .'_test-receipt-2.png;Transaction_'.$transaction->id.'_test-receipt-3.png',
60
                ]
61
            );
62
    }
63
64
    /**
65
     * Attachment file name will be provided as comma separated list in the transaction download.
66
     */
67
    public function testDownloadAttachment()
68
    {
69
        // Arrange
70
        /** @var Transaction $transaction */
71
        $transaction = factory(Transaction::class)->create();
72
        $this->addReceiptsToTransaction($transaction);
73
        $fileName = 'Transaction_'.$transaction->id.'_test-receipt-3.png';
74
        $url = $this->buildUrl('', ['download_attachment' => $fileName]);
75
76
        // Act
77
        $response = $this->get($url);
78
79
        // Assert
80
        $response->assertStatus(200)
81
            ->assertHeader('Content-Type', '')
82
            ->assertHeader('Cache-Control', 'public')
83
            ->assertHeader('Content-Description', 'File Transfer')
84
            ->assertHeader('Content-Disposition', 'attachment; filename= '.$fileName)
85
            ->assertHeader('Content-Transfer-Encoding', 'binary');
86
    }
87
88
    /**
89
     * @param $transaction
90
     */
91
    protected function addReceiptsToTransaction(Transaction $transaction)
92
    {
93
        $transaction->addAttachment(base_path('tests/data/test-receipt.png'), true);
94
        $transaction->addAttachment(base_path('tests/data/test-receipt-2.png'), true);
95
        $transaction->addAttachment(base_path('tests/data/test-receipt-3.png'), true);
96
    }
97
}
98