Completed
Push — master ( dadc2f...03811a )
by Alex
03:35
created

ListBuilderNoItemsCreateButtonUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateButtonAbsenceForEmptyList() 0 10 1
A actionsDataProvider() 0 25 1
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 ListBuilderNoItemsCreateButtonUnitTest 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