Creates the Twig\PmaGlobalVariable class to handle the 'pma' Twig global
variable.
The idea of this global variable is to automatically inject in all
templates some useful information.
For now it only includes `pma.version` to get the phpMyAdmin version
and `pma.text_dir` to get the text direction ('ltr' or 'rtl').
Adding new variables to the `pma` global variable should be done with
caution.
- https://twig.symfony.com/doc/3.x/advanced.html#globals
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Tests;
|
|
|
|
use PhpMyAdmin\Application;
|
|
use PhpMyAdmin\Config;
|
|
use PhpMyAdmin\Container\ContainerBuilder;
|
|
use PhpMyAdmin\Error\ErrorHandler;
|
|
use PhpMyAdmin\Exceptions\ConfigException;
|
|
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
|
use PhpMyAdmin\Template;
|
|
use PHPUnit\Framework\Attributes\BackupStaticProperties;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
#[CoversClass(Application::class)]
|
|
final class ApplicationTest extends AbstractTestCase
|
|
{
|
|
public function testInit(): void
|
|
{
|
|
$application = ContainerBuilder::getContainer()->get(Application::class);
|
|
self::assertInstanceOf(Application::class, $application);
|
|
self::assertSame($application, Application::init());
|
|
}
|
|
|
|
#[BackupStaticProperties(true)]
|
|
public function testRunWithConfigError(): void
|
|
{
|
|
$errorHandler = self::createStub(ErrorHandler::class);
|
|
|
|
$config = self::createMock(Config::class);
|
|
$config->expects(self::once())->method('loadAndCheck')
|
|
->willThrowException(new ConfigException('Failed to load phpMyAdmin configuration.'));
|
|
$config->config = new Config\Settings([]);
|
|
|
|
$template = new Template($config);
|
|
$expected = $template->render('error/generic', [
|
|
'lang' => 'en',
|
|
'error_message' => 'Failed to load phpMyAdmin configuration.',
|
|
]);
|
|
|
|
$application = new Application($errorHandler, $config, $template, ResponseFactory::create());
|
|
$application->run();
|
|
|
|
$output = $this->getActualOutputForAssertion();
|
|
self::assertSame($expected, $output);
|
|
}
|
|
}
|