Passed
Push — master ( 8747ce...da763d )
by Maurício
13:18 queued 28s
created

BrowseFormTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 51
dl 0
loc 66
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetFields() 0 22 1
A testRegisteredForms() 0 35 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\Tests\Config\Forms\Page;
6
7
use PhpMyAdmin\Config\ConfigFile;
8
use PhpMyAdmin\Config\Form;
9
use PhpMyAdmin\Config\FormDisplay;
10
use PhpMyAdmin\Config\Forms\BaseForm;
11
use PhpMyAdmin\Config\Forms\Page\BrowseForm;
12
use PhpMyAdmin\Tests\AbstractTestCase;
13
use PHPUnit\Framework\Attributes\CoversClass;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\Attributes\CoversClass was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
#[CoversClass(BrowseForm::class)]
16
#[CoversClass(BaseForm::class)]
17
#[CoversClass(FormDisplay::class)]
18
#[CoversClass(Form::class)]
19
final class BrowseFormTest extends AbstractTestCase
20
{
21
    public function testRegisteredForms(): void
22
    {
23
        Form::resetGroupCounter();
24
25
        $browseForm = new BrowseForm(new ConfigFile([]), 1);
26
        self::assertSame('', BrowseForm::getName());
27
28
        $forms = $browseForm->getRegisteredForms();
29
        self::assertCount(1, $forms);
30
31
        self::assertArrayHasKey('Browse', $forms);
0 ignored issues
show
Bug introduced by
It seems like $forms can also be of type Countable; however, parameter $array of PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept ArrayAccess|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        self::assertArrayHasKey('Browse', /** @scrutinizer ignore-type */ $forms);
Loading history...
32
        $form = $forms['Browse'];
33
        self::assertSame('Browse', $form->name);
34
        self::assertSame(1, $form->index);
35
        self::assertSame([], $form->default);
36
        self::assertSame(
37
            [
38
                'TableNavigationLinksMode' => 'TableNavigationLinksMode',
39
                'ActionLinksMode' => 'ActionLinksMode',
40
                'ShowAll' => 'ShowAll',
41
                'MaxRows' => 'MaxRows',
42
                'Order' => 'Order',
43
                'BrowsePointerEnable' => 'BrowsePointerEnable',
44
                'BrowseMarkerEnable' => 'BrowseMarkerEnable',
45
                'GridEditing' => 'GridEditing',
46
                'SaveCellsAtOnce' => 'SaveCellsAtOnce',
47
                'RepeatCells' => 'RepeatCells',
48
                'LimitChars' => 'LimitChars',
49
                'RowActionLinks' => 'RowActionLinks',
50
                'RowActionLinksWithoutUnique' => 'RowActionLinksWithoutUnique',
51
                'TablePrimaryKeyOrder' => 'TablePrimaryKeyOrder',
52
                'RememberSorting' => 'RememberSorting',
53
                'RelationalDisplay' => 'RelationalDisplay',
54
            ],
55
            $form->fields,
56
        );
57
    }
58
59
    public function testGetFields(): void
60
    {
61
        self::assertSame(
62
            [
63
                'TableNavigationLinksMode',
64
                'ActionLinksMode',
65
                'ShowAll',
66
                'MaxRows',
67
                'Order',
68
                'BrowsePointerEnable',
69
                'BrowseMarkerEnable',
70
                'GridEditing',
71
                'SaveCellsAtOnce',
72
                'RepeatCells',
73
                'LimitChars',
74
                'RowActionLinks',
75
                'RowActionLinksWithoutUnique',
76
                'TablePrimaryKeyOrder',
77
                'RememberSorting',
78
                'RelationalDisplay',
79
            ],
80
            BrowseForm::getFields(),
81
        );
82
    }
83
}
84