phpmyadmin/test/classes/Controllers/JavaScriptMessagesControllerTest.php
Maurício Meneghini Fauth 3f2c53ef1d
Replace PHPUnit annotations with attributes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-06-07 11:44:01 -03:00

36 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers;
use PhpMyAdmin\Controllers\JavaScriptMessagesController;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;
use function json_decode;
use function strlen;
use function substr;
#[CoversClass(JavaScriptMessagesController::class)]
class JavaScriptMessagesControllerTest extends TestCase
{
#[RunInSeparateProcess]
public function testIndex(): void
{
(new JavaScriptMessagesController())();
$actual = $this->getActualOutputForAssertion();
$this->assertStringStartsWith('window.Messages = {', $actual);
$this->assertStringEndsWith('};', $actual);
$json = substr($actual, strlen('window.Messages = '), -1);
$array = json_decode($json, true);
$this->assertIsArray($array);
$this->assertArrayHasKey('strDoYouReally', $array);
$this->assertEquals('Do you really want to execute "%s"?', $array['strDoYouReally']);
}
}