Passed
Push — master ( 39e51c...ca88cb )
by Alex
03:38
created

testCreateButtonAbsenceForEmptyList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
1
<?php
2
namespace Mezon\Gui\Tests\Common;
3
4
use Mezon\Gui\ListBuilder;
5
use Mezon\Gui\Tests\FakeAdapter;
6
use Mezon\Gui\Tests\ListBuilderTestsBase;
7
8
class NoItemsCreateButtonUnitTest extends ListBuilderTestsBase
9
{
10
11
    /**
12
     * Testing data provider
13
     *
14
     * @return array testing data
15
     */
16
    public function actionsDataProvider(): array
17
    {
18
        return [
19
            // #0, the first case - empty listing
20
            [
21
                function (): object {
22
                    // setup
23
                    unset($_GET['create-button']);
24
                    return new ListBuilder\Common($this->getFields(), new FakeAdapter([]));
25
                },
26
                function ($result): void {
27
                    // asserting method
28
                    $this->assertStringNotContainsString('create-button"', $result);
29
                }
30
            ],
31
            // #1, the second case - full header
32
            [
33
                function (): object {
34
                    // setup
35
                    $_GET['create-button'] = 1;
36
                    return new ListBuilder\Common($this->getFields(), new FakeAdapter([]));
37
                },
38
                function ($result): void {
39
                    // asserting method
40
                    $this->assertStringContainsString('../create/', $result);
41
                }
42
            ],
43
        ];
44
    }
45
46
    /**
47
     * Testing create button absence
48
     *
49
     * * @dataProvider actionsDataProvider
50
     */
51
    public function testCreateButtonAbsenceForEmptyList(callable $setup, callable $assertions): void
52
    {
53
        // setup
54
        $obj = $setup();
55
56
        // test body
57
        $result = $obj->listingForm();
58
59
        // assertions
60
        $assertions($result);
61
    }
62
}
63