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

ListBuilderNoItemsCreateButtonUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 11
c 1
b 1
f 0
dl 0
loc 47
rs 10
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
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 - without button
20
            [
21
                function (): object {
22
                    // setup
23
                    unset($_GET['create-button']);
24
                    return new ListBuilder\Simple($this->getFields(), new FakeAdapter([]));
25
                }
26
            ],
27
            // #1, the second case - without button, even if we try to display it
28
            [
29
                function (): object {
30
                    // setup
31
                    $_GET['create-button'] = 1;
32
                    return new ListBuilder\Simple($this->getFields(), new FakeAdapter([]));
33
                }
34
            ],
35
        ];
36
    }
37
38
    /**
39
     * Testing create button absence
40
     *
41
     * @param callable $setup
42
     *            setup method
43
     * @dataProvider actionsDataProvider
44
     */
45
    public function testCreateButtonAbsenceForEmptyList(callable $setup): void
46
    {
47
        // setup
48
        $obj = $setup();
49
50
        // test body
51
        $result = $obj->listingForm();
52
53
        // assertions
54
        $this->assertStringNotContainsString('create-button"', $result);
55
    }
56
}
57