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

CategoryTest::testDeleteAllCategories()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Tests\Feature\MmexClient;
4
5
use App\Models\Category;
6
use Tests\Feature\Api\AbstractMmexTestCase;
7
use Tests\TestCase;
8
9
class CategoryTest extends AbstractMmexTestCase
10
{
11
12 View Code Duplication
    public function testDeleteAllCategories()
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...
13
    {
14
        // Arrange
15
        $categorie = factory(Category::class)->create();
16
17
        $url = $this->buildUrl('', ['delete_category' => 'true']);
18
19
        // Act
20
        $response = $this->get($url);
21
22
        // Assert
23
        $this->seeSuccess($response);
24
        $this->assertDatabaseMissing('categories', ['name' => $categorie->name]);
25
    }
26
27
    public function testImportCategories()
28
    {
29
        // Arrange
30
        $data = ['MMEX_Post' => '{ "Categories" : [ { "CategoryName" : "Bills", "SubCategoryName" : "Telecom" }, { "CategoryName" : "Bills", "SubCategoryName" : "Water" }, { "CategoryName" : "Automobile", "SubCategoryName" : "Maintenance" }, { "CategoryName" : "Automobile", "SubCategoryName" : "Parking" } ] }'];
31
        $url = $this->buildUrl('', ['import_category' => 'true']);
32
33
        // Act
34
        $response = $this->postJson($url, $data);
35
36
        // Assert
37
        $this->seeSuccess($response);
38
        $this->assertDatabaseHas('categories', ['name' => 'Bills']);
39
        $this->assertDatabaseHas('categories', ['name' => 'Telecom']);
40
        $this->assertDatabaseHas('categories', ['name' => 'Water']);
41
        $this->assertDatabaseHas('categories', ['name' => 'Automobile']);
42
        $this->assertDatabaseHas('categories', ['name' => 'Maintenance']);
43
        $this->assertDatabaseHas('categories', ['name' => 'Parking']);
44
    }
45
46
    public function testImportSubCategories()
47
    {
48
        // Arrange
49
        $data = ['MMEX_Post' => '{ "Categories" : [ { "CategoryName" : "Bills", "SubCategoryName" : "Telecom" }, { "CategoryName" : "Bills", "SubCategoryName" : "Water" }, { "CategoryName" : "Automobile", "SubCategoryName" : "Maintenance" }, { "CategoryName" : "Automobile", "SubCategoryName" : "Parking" } ] }'];
50
        $url = $this->buildUrl('', ['import_category' => 'true']);
51
52
        $bills = factory(Category::class)->create(['name' => 'Bills']);
53
        $automobile = factory(Category::class)->create(['name' => 'Automobile']);
54
55
        // Act
56
        $response = $this->postJson($url, $data);
57
58
        // Assert
59
        $this->seeSuccess($response);
60
        $this->assertDatabaseHas('categories', ['name' => 'Bills', 'id' => $bills->id]);
61
        $this->assertDatabaseHas('categories', ['name' => 'Telecom', 'parent_id' => $bills->id]);
62
        $this->assertDatabaseHas('categories', ['name' => 'Water', 'parent_id' => $bills->id]);
63
        $this->assertDatabaseHas('categories', ['name' => 'Automobile', 'id' => $automobile->id]);
64
        $this->assertDatabaseHas('categories', ['name' => 'Maintenance', 'parent_id' => $automobile->id]);
65
        $this->assertDatabaseHas('categories', ['name' => 'Parking', 'parent_id' => $automobile->id]);
66
    }
67
}
68