Passed
Push — master ( 4d86c4...586e6b )
by Alex
02:58
created

NoItemsCreateButtonUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateButtonAbsenceForEmptyList() 0 10 1
A actionsDataProvider() 0 17 1
1
<?php
2
namespace Mezon\Gui\Tests\Simple;
3
4
use Mezon\Gui\ListBuilder;
5
use Mezon\Gui\Tests\FakeAdapter;
6
use Mezon\Gui\Tests\ListBuilderTestsBase;
7
8
/**
9
 *
10
 * @psalm-suppress PropertyNotSetInConstructor
11
 */
12
class NoItemsCreateButtonUnitTest extends ListBuilderTestsBase
13
{
14
15
    /**
16
     * Testing data provider
17
     *
18
     * @return array testing data
19
     */
20
    public function actionsDataProvider(): array
21
    {
22
        return [
23
            // #0, the first case - without button
24
            [
25
                function (): object {
26
                    // setup
27
                    unset($_GET['create-button']);
28
                    return new ListBuilder\Simple($this->getFields(), new FakeAdapter([]));
29
                }
30
            ],
31
            // #1, the second case - without button, even if we try to display it
32
            [
33
                function (): object {
34
                    // setup
35
                    $_GET['create-button'] = 1;
36
                    return new ListBuilder\Simple($this->getFields(), new FakeAdapter([]));
37
                }
38
            ],
39
        ];
40
    }
41
42
    /**
43
     * Testing create button absence
44
     *
45
     * @param callable $setup
46
     *            setup method
47
     * @dataProvider actionsDataProvider
48
     */
49
    public function testCreateButtonAbsenceForEmptyList(callable $setup): void
50
    {
51
        // setup
52
        $obj = $setup();
53
54
        // test body
55
        $result = $obj->listingForm();
56
57
        // assertions
58
        $this->assertStringNotContainsString('create-button"', $result);
59
    }
60
}
61