Merge branch 'origin/master' into Weblate.
[phpmyadmin.git] / tests / classes / ResponseRendererTest.php
blob0b2dfbbb4d6e09cfc54b3db6572dac9aa0e3837f
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';
26 $GLOBALS['server'] = 1;
27 $GLOBALS['text_dir'] = 'ltr';
30 #[RunInSeparateProcess]
31 #[PreserveGlobalState(false)]
32 public function testSetAjax(): void
34 $_REQUEST = [];
35 $response = ResponseRenderer::getInstance();
36 $header = $response->getHeader();
37 $footer = (new ReflectionProperty(ResponseRenderer::class, 'footer'))->getValue($response);
38 $this->assertInstanceOf(Footer::class, $footer);
39 $headerIsAjax = new ReflectionProperty(Header::class, 'isAjax');
40 $footerIsAjax = new ReflectionProperty(Footer::class, 'isAjax');
42 $this->assertFalse($response->isAjax());
43 $this->assertFalse($headerIsAjax->getValue($header));
44 $this->assertFalse($footerIsAjax->getValue($footer));
46 $response->setAjax(true);
47 $this->assertTrue($response->isAjax());
48 $this->assertTrue($headerIsAjax->getValue($header));
49 $this->assertTrue($footerIsAjax->getValue($footer));
51 $response->setAjax(false);
52 $this->assertFalse($response->isAjax());
53 $this->assertFalse($headerIsAjax->getValue($header));
54 $this->assertFalse($footerIsAjax->getValue($footer));