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.

PayeeTest::testImportPayees()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace Tests\Feature\MmexClient;
4
5
use App\Models\Category;
6
use App\Models\Payee;
7
8
class PayeeTest extends MmexTestCase
9
{
10 View Code Duplication
    public function testDeleteAllPayees()
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...
11
    {
12
        // Arrange
13
        $payee = factory(Payee::class)->create(['user_id' => $this->user->id]);
14
        $url = $this->buildUrl(['delete_payee' => 'true']);
15
16
        // Act
17
        $response = $this->get($url);
18
19
        // Assert
20
        $this->assertSeeMmexSuccess($response);
21
        $this->assertIsSoftDeletedInDatabase('payees', ['user_id' => $this->user->id, 'name' => $payee->name]);
22
    }
23
24
    public function testImportPayees()
25
    {
26
        // Arrange
27
        $food = factory(Category::class)->create(['user_id' => $this->user->id, 'name' => 'Food']);
28
        $foodPurchases = factory(Category::class)->create(['user_id' => $this->user->id, 'name' => 'Purchases', 'parent_id' => $food->id]);
29
        $bills = factory(Category::class)->create(['user_id' => $this->user->id, 'name' => 'Bills']);
30
        $billsServices = factory(Category::class)->create(['user_id' => $this->user->id, 'name' => 'Services', 'parent_id' => $bills->id]);
31
32
        $data = ['MMEX_Post' => '{ "Payees" : [ { "PayeeName" : "Mc Donalds", "DefCateg" : "'.$food->name.'", "DefSubCateg" : "'.$foodPurchases->name.'" },'.
33
            '{ "PayeeName" : "Spotify", "DefCateg" : "'.$bills->name.'", "DefSubCateg" : "'.$billsServices->name.'" } ] }', ];
34
35
        $url = $this->buildUrl(['import_payee' => 'true']);
36
37
        // Act
38
        $response = $this->postJson($url, $data);
39
40
        // Assert
41
        $this->assertSeeMmexSuccess($response);
42
        $this->assertDatabaseHas('payees', ['user_id' => $this->user->id, 'name' => 'Mc Donalds', 'last_category_id' => $foodPurchases->id]);
43
        $this->assertDatabaseHas('payees', ['user_id' => $this->user->id, 'name' => 'Spotify', 'last_category_id' => $billsServices->id]);
44
    }
45
46
    public function testEnsureSoftDeletedPayeesWillBeRestored()
47
    {
48
        // Arrange
49
        $payee1 = factory(Payee::class)->create(['user_id' => $this->user->id, 'name' => 'Luke Skywalker']);
50
        $payee2 = factory(Payee::class)->create(['user_id' => $this->user->id, 'name' => 'Yoda']);
51
52
        // will soft delete entries
53
        $payee1->delete();
54
        $payee2->delete();
55
56
        $data = ['MMEX_Post' => '{ "Payees" : [ { "PayeeName" : "Luke Skywalker", "DefCateg" : "None", "DefSubCateg" : "None" },'.
57
            '{ "PayeeName" : "Yoda", "DefCateg" : "None", "DefSubCateg" : "None" } ] }', ];
58
59
        $url = $this->buildUrl(['import_payee' => 'true']);
60
61
        // Act
62
        $response = $this->postJson($url, $data);
63
64
        // Assert
65
        $this->assertSeeMmexSuccess($response);
66
        $this->assertDatabaseHas('payees', ['user_id' => $this->user->id, 'name' => 'Luke Skywalker', 'deleted_at' => null]);
67
        $this->assertDatabaseHas('payees', ['user_id' => $this->user->id, 'name' => 'Yoda', 'deleted_at' => null]);
68
    }
69
70
    /**
71
     * @test
72
     */
73
    public function it_creates_default_categories_for_payees()
74
    {
75
        // Arrange
76
        $data = ['MMEX_Post' => '{ "Payees" : [ { "PayeeName" : "Mc Donalds", "DefCateg" : "Food", "DefSubCateg" : "Purchase" },'.
77
            '{ "PayeeName" : "Spotify", "DefCateg" : "Bills", "DefSubCateg" : "Services" } ] }', ];
78
79
        $url = $this->buildUrl(['import_payee' => 'true']);
80
81
        // Act
82
        $response = $this->postJson($url, $data);
83
84
        // Assert
85
        $this->assertSeeMmexSuccess($response);
86
        $category1 = $this->assertDatabaseHasOnceAndReturnFirst('categories', ['user_id' => $this->user->id, 'name' => 'Food']);
87
        $category2 = $this->assertDatabaseHasOnceAndReturnFirst('categories', ['user_id' => $this->user->id, 'name' => 'Bills']);
88
89
        $subcategory1 = $this->assertDatabaseHasOnceAndReturnFirst('categories', ['user_id' => $this->user->id, 'name' => 'Purchase', 'parent_id' => $category1->id]);
90
        $subcategory2 = $this->assertDatabaseHasOnceAndReturnFirst('categories', ['user_id' => $this->user->id, 'name' => 'Services', 'parent_id' => $category2->id]);
91
92
        $this->assertDatabaseHas('payees', ['user_id' => $this->user->id, 'name' => 'Mc Donalds', 'last_category_id' => $subcategory1->id]);
93
        $this->assertDatabaseHas('payees', ['user_id' => $this->user->id, 'name' => 'Spotify', 'last_category_id' => $subcategory2->id]);
94
    }
95
}
96