You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-23 18:29:15 +03:00
Rename tests/classes to tests/unit
This directory is for unit tests only, so let's rename it to unit to be more clear. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
38
tests/unit/Controllers/JavaScriptMessagesControllerTest.php
Normal file
38
tests/unit/Controllers/JavaScriptMessagesControllerTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Controllers;
|
||||
|
||||
use Fig\Http\Message\StatusCodeInterface;
|
||||
use PhpMyAdmin\Controllers\JavaScriptMessagesController;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
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
|
||||
{
|
||||
$response = (new JavaScriptMessagesController(ResponseFactory::create()))();
|
||||
$actual = (string) $response->getBody();
|
||||
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
|
||||
|
||||
self::assertStringStartsWith('window.Messages = {', $actual);
|
||||
self::assertStringEndsWith('};', $actual);
|
||||
|
||||
$json = substr($actual, strlen('window.Messages = '), -1);
|
||||
$array = json_decode($json, true);
|
||||
|
||||
self::assertIsArray($array);
|
||||
self::assertArrayHasKey('strDoYouReally', $array);
|
||||
self::assertSame('Do you really want to execute "%s"?', $array['strDoYouReally']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user