diff --git a/libraries/classes/Console.php b/libraries/classes/Console.php
index c416355939..38492f090d 100644
--- a/libraries/classes/Console.php
+++ b/libraries/classes/Console.php
@@ -31,7 +31,7 @@ class Console
*
* @var bool
*/
- private $isAjax;
+ private $isAjax = false;
/** @var Relation */
private $relation;
diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php
index 29c5d981f4..075644a39f 100644
--- a/libraries/classes/Footer.php
+++ b/libraries/classes/Footer.php
@@ -36,7 +36,7 @@ class Footer
*
* @var bool
*/
- private $isAjax;
+ private $isAjax = false;
/**
* Whether to only close the BODY and HTML tags
* or also include scripts, errors and links
diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php
index 788db33931..d462d0031b 100644
--- a/libraries/classes/Header.php
+++ b/libraries/classes/Header.php
@@ -76,7 +76,7 @@ class Header
*
* @var bool
*/
- private $isAjax;
+ private $isAjax = false;
/**
* Whether to display anything
*
@@ -107,7 +107,6 @@ class Header
$this->template = new Template();
$this->isEnabled = true;
- $this->isAjax = false;
$this->bodyId = '';
$this->title = '';
$this->console = new Console();
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index cbd0460f02..7b3e184bf6 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -995,11 +995,6 @@
$tabs
-
-
- $isAjax
-
-
$db
@@ -6820,9 +6815,6 @@
array{revision: string, revisionUrl: string, branch: string, branchUrl: string}|[]
is_array($info) ? $info : []
-
- $isAjax
-
(string) $GLOBALS['db']
(string) $GLOBALS['table']
diff --git a/test/classes/ConsoleTest.php b/test/classes/ConsoleTest.php
index 23ebd5ec3a..7aeaecceea 100644
--- a/test/classes/ConsoleTest.php
+++ b/test/classes/ConsoleTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Console;
+use ReflectionProperty;
/**
* @covers \PhpMyAdmin\Console
@@ -16,4 +17,17 @@ class ConsoleTest extends AbstractTestCase
$console = new Console();
$this->assertEquals(['console.js'], $console->getScripts());
}
+
+ public function testSetAjax(): void
+ {
+ $isAjax = new ReflectionProperty(Console::class, 'isAjax');
+ $isAjax->setAccessible(true);
+ $console = new Console();
+
+ $this->assertFalse($isAjax->getValue($console));
+ $console->setAjax(true);
+ $this->assertTrue($isAjax->getValue($console));
+ $console->setAjax(false);
+ $this->assertFalse($isAjax->getValue($console));
+ }
}
diff --git a/test/classes/FooterTest.php b/test/classes/FooterTest.php
index 679734704f..393a56b9c6 100644
--- a/test/classes/FooterTest.php
+++ b/test/classes/FooterTest.php
@@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests;
use ArrayIterator;
use PhpMyAdmin\ErrorHandler;
use PhpMyAdmin\Footer;
+use ReflectionProperty;
use function json_encode;
@@ -116,10 +117,7 @@ class FooterTest extends AbstractTestCase
);
}
- /**
- * Test for footer when ajax enabled
- */
- public function testAjax(): void
+ public function testGetDisplayWhenAjaxIsEnabled(): void
{
$footer = new Footer();
$footer->setAjax(true);
@@ -167,4 +165,17 @@ class FooterTest extends AbstractTestCase
$footer->getDisplay()
);
}
+
+ public function testSetAjax(): void
+ {
+ $isAjax = new ReflectionProperty(Footer::class, 'isAjax');
+ $isAjax->setAccessible(true);
+ $footer = new Footer();
+
+ $this->assertFalse($isAjax->getValue($footer));
+ $footer->setAjax(true);
+ $this->assertTrue($isAjax->getValue($footer));
+ $footer->setAjax(false);
+ $this->assertFalse($isAjax->getValue($footer));
+ }
}
diff --git a/test/classes/HeaderTest.php b/test/classes/HeaderTest.php
index 20a17bd698..c9aa4f16a7 100644
--- a/test/classes/HeaderTest.php
+++ b/test/classes/HeaderTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests;
+use PhpMyAdmin\Console;
use PhpMyAdmin\Core;
use PhpMyAdmin\Header;
use ReflectionProperty;
@@ -245,4 +246,26 @@ class HeaderTest extends AbstractTestCase
],
];
}
+
+ public function testSetAjax(): void
+ {
+ $header = new Header();
+ $consoleReflection = new ReflectionProperty(Header::class, 'console');
+ $consoleReflection->setAccessible(true);
+ $console = $consoleReflection->getValue($header);
+ $this->assertInstanceOf(Console::class, $console);
+ $isAjax = new ReflectionProperty(Header::class, 'isAjax');
+ $isAjax->setAccessible(true);
+ $consoleIsAjax = new ReflectionProperty(Console::class, 'isAjax');
+ $consoleIsAjax->setAccessible(true);
+
+ $this->assertFalse($isAjax->getValue($header));
+ $this->assertFalse($consoleIsAjax->getValue($console));
+ $header->setAjax(true);
+ $this->assertTrue($isAjax->getValue($header));
+ $this->assertTrue($consoleIsAjax->getValue($console));
+ $header->setAjax(false);
+ $this->assertFalse($isAjax->getValue($header));
+ $this->assertFalse($consoleIsAjax->getValue($console));
+ }
}
diff --git a/test/classes/ResponseRendererTest.php b/test/classes/ResponseRendererTest.php
new file mode 100644
index 0000000000..dddd95b337
--- /dev/null
+++ b/test/classes/ResponseRendererTest.php
@@ -0,0 +1,59 @@
+getHeader();
+ $footerReflection = new ReflectionProperty(ResponseRenderer::class, 'footer');
+ $footerReflection->setAccessible(true);
+ $footer = $footerReflection->getValue($response);
+ $this->assertInstanceOf(Footer::class, $footer);
+ $headerIsAjax = new ReflectionProperty(Header::class, 'isAjax');
+ $headerIsAjax->setAccessible(true);
+ $footerIsAjax = new ReflectionProperty(Footer::class, 'isAjax');
+ $footerIsAjax->setAccessible(true);
+
+ $this->assertFalse($response->isAjax());
+ $this->assertFalse($headerIsAjax->getValue($header));
+ $this->assertFalse($footerIsAjax->getValue($footer));
+
+ $response->setAjax(true);
+ $this->assertTrue($response->isAjax());
+ $this->assertTrue($headerIsAjax->getValue($header));
+ $this->assertTrue($footerIsAjax->getValue($footer));
+
+ $response->setAjax(false);
+ $this->assertFalse($response->isAjax());
+ $this->assertFalse($headerIsAjax->getValue($header));
+ $this->assertFalse($footerIsAjax->getValue($footer));
+ }
+}
diff --git a/test/classes/ResponseTest.php b/test/classes/ResponseTest.php
deleted file mode 100644
index 4593b06bee..0000000000
--- a/test/classes/ResponseTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-setAjax(true);
- $this->assertTrue($response->isAjax());
- $response->setAjax(false);
- $this->assertFalse($response->isAjax());
- }
-}