3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests
;
7 use PhpMyAdmin\DatabaseInterface
;
10 use PhpMyAdmin\ResponseRenderer
;
11 use PHPUnit\Framework\Attributes\CoversClass
;
12 use PHPUnit\Framework\Attributes\PreserveGlobalState
;
13 use PHPUnit\Framework\Attributes\RunInSeparateProcess
;
14 use ReflectionProperty
;
16 #[CoversClass(ResponseRenderer::class)]
17 class ResponseRendererTest
extends AbstractTestCase
19 protected function setUp(): void
23 DatabaseInterface
::$instance = $this->createDatabaseInterface();
25 $GLOBALS['lang'] = 'en';
28 #[RunInSeparateProcess]
29 #[PreserveGlobalState(false)]
30 public function testSetAjax(): void
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');
40 $this->assertFalse($response->isAjax());
41 $this->assertFalse($headerIsAjax->getValue($header));
42 $this->assertFalse($footerIsAjax->getValue($footer));
44 $response->setAjax(true);
45 $this->assertTrue($response->isAjax());
46 $this->assertTrue($headerIsAjax->getValue($header));
47 $this->assertTrue($footerIsAjax->getValue($footer));
49 $response->setAjax(false);
50 $this->assertFalse($response->isAjax());
51 $this->assertFalse($headerIsAjax->getValue($header));
52 $this->assertFalse($footerIsAjax->getValue($footer));