Passed
Push — master ( 586e6b...5b2592 )
by Alex
03:06
created

CreateButtonUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testCreateButtonFromSetting() 0 14 1
1
<?php
2
namespace Mezon\Gui\Tests\Common;
3
4
use Mezon\Gui\ListBuilder;
5
use Mezon\Gui\Tests\ListBuilderTestsBase;
6
use Mezon\Gui\Tests\FakeAdapter;
7
use PHPUnit\Framework\TestCase;
8
use Mezon\Conf\Conf;
9
10
/**
11
 *
12
 * @psalm-suppress PropertyNotSetInConstructor
13
 */
14
class CreateButtonUnitTest extends ListBuilderTestsBase
15
{
16
17
    /**
18
     *
19
     * {@inheritdoc}
20
     * @see TestCase::setUp()
21
     * @psalm-suppress RedundantCondition
22
     */
23
    protected function setUp(): void
24
    {
25
        Conf::setConfigStringValue('headers/layer', 'mock');
26
    }
27
28
    /**
29
     * Testing generating create button from setting
30
     */
31
    public function testCreateButtonFromSetting(): void
32
    {
33
        // setup
34
        $_GET['create-page-endpoint'] = '/create-endpoint/';
35
        $_GET['create-button'] = 1;
36
        $listBuilder = new ListBuilder\Common($this->getFields(), new FakeAdapter($this->getRecords()));
37
        $listBuilder->createButtonEndpoint = '/create-endpoint-from-setting/';
38
        $listBuilder->listTitle = 'Some list title';
39
40
        // test body
41
        $content = $listBuilder->listingForm();
42
43
        // assertions
44
        $this->assertStringContainsString("/create-endpoint-from-setting/", $content);
45
    }
46
}
47