Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 861d7d...2ad8d1 )
by Cristian
04:38
created

CrudPanelFakeColumnsTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 88
rs 10
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetFakeColumnsAsArrayFromCreateForm() 0 12 1
A testGetFakeColumnsAsArrayFromUpdateForm() 0 12 1
A testGetFakeColumnsAsArrayEmpty() 0 6 1
A testGetFakeColumnsAsArrayFromUnknownForm() 0 12 1
1
<?php
2
3
namespace Backpack\CRUD\Tests\Unit\CrudPanel;
4
5
use Backpack\CRUD\Tests\Unit\Models\Article;
6
7
class CrudPanelFakeColumnsTest extends BaseDBCrudPanelTest
8
{
9
    private $emptyFakeColumnsArray = ['extras'];
10
11
    private $fakeFieldsArray = [
12
        [
13
            'name' => 'field',
14
            'label' => 'Normal Field',
15
        ],
16
        [
17
            'name' => 'meta_title',
18
            'label' => 'Meta Title',
19
            'fake' => true,
20
            'store_in' => 'metas',
21
        ],
22
        [
23
            'name' => 'meta_description',
24
            'label' => 'Meta Description',
25
            'fake' => true,
26
            'store_in' => 'metas',
27
        ],
28
        [
29
            'name' => 'meta_keywords',
30
            'label' => 'Meta Keywords',
31
            'fake' => true,
32
            'store_in' => 'metas',
33
        ],
34
        [
35
            'name' => 'tags',
36
            'label' => 'Tags',
37
            'fake' => true,
38
            'store_in' => 'tags',
39
        ],
40
        [
41
            'name' => 'extra_details',
42
            'label' => 'Extra Details',
43
            'fake' => true,
44
        ],
45
    ];
46
47
    private $expectedFakeFieldsColumnNames = ['metas', 'tags', 'extras'];
48
49
    public function testGetFakeColumnsAsArrayFromCreateForm()
50
    {
51
        $this->crudPanel->setModel(Article::class);
52
53
        $this->crudPanel->addFields($this->fakeFieldsArray, 'create');
54
55
        $createFakeColumnsArray = $this->crudPanel->getFakeColumnsAsArray();
56
        $updateFakeColumnsArray = $this->crudPanel->getFakeColumnsAsArray('update', 1);
57
58
        $this->assertEquals($this->expectedFakeFieldsColumnNames, $createFakeColumnsArray);
59
        $this->assertEquals($this->emptyFakeColumnsArray, $updateFakeColumnsArray);
60
    }
61
62
    public function testGetFakeColumnsAsArrayFromUpdateForm()
63
    {
64
        $this->crudPanel->setModel(Article::class);
65
66
        $this->crudPanel->addFields($this->fakeFieldsArray, 'update');
67
68
        $createFakeColumnsArray = $this->crudPanel->getFakeColumnsAsArray();
69
        $updateFakeColumnsArray = $this->crudPanel->getFakeColumnsAsArray('update', 1);
70
71
        $this->assertEquals($this->emptyFakeColumnsArray, $createFakeColumnsArray);
72
        $this->assertEquals($this->expectedFakeFieldsColumnNames, $updateFakeColumnsArray);
73
    }
74
75
    public function testGetFakeColumnsAsArrayEmpty()
76
    {
77
        $fakeColumnsArray = $this->crudPanel->getFakeColumnsAsArray();
78
79
        $this->assertEquals($this->emptyFakeColumnsArray, $fakeColumnsArray);
80
    }
81
82
    public function testGetFakeColumnsAsArrayFromUnknownForm()
83
    {
84
        $this->markTestIncomplete('Not correctly implemented');
85
86
        $this->setExpectedException(\InvalidArgumentException::class);
87
88
        // TODO: this should throw an invalid argument exception but doesn't because of the getFields method in the
89
        //       read trait, which returns the create fields in case of an unknown form type.
90
        //       also, the getFields method should probably be renamed, as it also populates the update fields values
91
        //       from the database
92
        $this->crudPanel->getFakeColumnsAsArray('unknownForm');
93
    }
94
}
95