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 ( ad2267...b1fe86 )
by Oliver
07:49
created

TransactionTest::testDownloadAttachment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
dl 20
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
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\Api;
13
14
use App\Models\Transaction;
15
16
class TransactionTest extends AbstractMmexTestCase
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 View Code Duplication
    public function testDownloadTransactions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 View Code Duplication
    public function testDownloadAttachment()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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