phpmyadmin/test/classes/Display/ErrorTest.php
Hugues Peccatte cccd820914 Add Display/ErrorTest class
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
2019-05-05 22:12:29 +02:00

83 lines
1.8 KiB
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for PhpMyAdmin\Display\Error
*
* @package PhpMyAdmin-test
*/
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Display;
use PhpMyAdmin\Display\Error;
use PhpMyAdmin\Template;
use PHPUnit\Framework\TestCase;
require_once ROOT_PATH . 'libraries/config.default.php';
/**
* ErrorTest class
*
* this class is for testing PhpMyAdmin\Display\Error functions
*
* @package PhpMyAdmin-test
*/
class ErrorTest extends TestCase
{
/**
* Test for Error::display
*
* @return void
* @throws \Throwable
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function testDisplaySimple(): void
{
$lang = 'fr';
$dir = 'ltr';
$error_header = 'Error';
$error_message = 'Failure';
$html = Error::display(new Template(), $lang, $dir, $error_header, $error_message);
$this->assertStringContainsString(
'<html lang="fr" dir="ltr">',
$html
);
$this->assertStringContainsString(
'Failure',
$html
);
}
/**
* Test for Error::display
*
* @return void
* @throws \Throwable
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function testDisplayToSanitize(): void
{
$lang = 'fr';
$dir = 'ltr';
$error_header = 'Error';
$error_message = '[em]Failure[/em]';
$html = Error::display(new Template(), $lang, $dir, $error_header, $error_message);
$this->assertStringContainsString(
'<html lang="fr" dir="ltr">',
$html
);
$this->assertStringContainsString(
'<em>Failure</em>',
$html
);
}
}