Replace text_dir global var with LanguageManager::$textDir static
[phpmyadmin.git] / tests / classes / ResponseRendererTest.php
blob496c56caf0da711290794aede165ecf99fc5af72
1 <?php
3 declare(strict_types=1);
5 namespace PhpMyAdmin\Tests;
7 use PhpMyAdmin\DatabaseInterface;
8 use PhpMyAdmin\Footer;
9 use PhpMyAdmin\Header;
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
21 parent::setUp();
23 DatabaseInterface::$instance = $this->createDatabaseInterface();
25 $GLOBALS['lang'] = 'en';
28 #[RunInSeparateProcess]
29 #[PreserveGlobalState(false)]
30 public function testSetAjax(): void
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');
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));