Passed
Push — master ( 1e2114...b11d81 )
by Maurício
10:27 queued 12s
created

ResponseRendererTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetAjax() 0 25 1
A setUp() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\Tests;
6
7
use PhpMyAdmin\Footer;
8
use PhpMyAdmin\Header;
9
use PhpMyAdmin\ResponseRenderer;
0 ignored issues
show
Bug introduced by
The type PhpMyAdmin\ResponseRenderer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use PHPUnit\Framework\Attributes\PreserveGlobalState;
11
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
12
use ReflectionProperty;
13
14
/** @covers \PhpMyAdmin\ResponseRenderer */
15
class ResponseRendererTest extends AbstractTestCase
16
{
17
    protected function setUp(): void
18
    {
19
        parent::setUp();
20
21
        $GLOBALS['dbi'] = $this->createDatabaseInterface();
22
23
        $GLOBALS['lang'] = 'en';
24
        $GLOBALS['server'] = 1;
25
        $GLOBALS['text_dir'] = 'ltr';
26
    }
27
28
    #[RunInSeparateProcess]
29
    #[PreserveGlobalState(false)]
30
    public function testSetAjax(): void
31
    {
32
        $_REQUEST = [];
33
        $response = ResponseRenderer::getInstance();
34
        $header = $response->getHeader();
35
        $footer = (new ReflectionProperty(ResponseRenderer::class, 'footer'))->getValue($response);
36
        $this->assertInstanceOf(Footer::class, $footer);
37
        $headerIsAjax = new ReflectionProperty(Header::class, 'isAjax');
38
        $footerIsAjax = new ReflectionProperty(Footer::class, 'isAjax');
39
40
        $this->assertFalse($response->isAjax());
41
        $this->assertFalse($headerIsAjax->getValue($header));
42
        $this->assertFalse($footerIsAjax->getValue($footer));
43
44
        $response->setAjax(true);
45
        $this->assertTrue($response->isAjax());
46
        $this->assertTrue($headerIsAjax->getValue($header));
47
        $this->assertTrue($footerIsAjax->getValue($footer));
48
49
        $response->setAjax(false);
50
        $this->assertFalse($response->isAjax());
51
        $this->assertFalse($headerIsAjax->getValue($header));
52
        $this->assertFalse($footerIsAjax->getValue($footer));
53
    }
54
}
55