Skip to content

Commit

Permalink
Add unit test for Session::secure()
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 25, 2024
1 parent a5b7249 commit 70425ba
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/SessionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace PhpMyAdmin\Tests;

use PhpMyAdmin\Session;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;

#[CoversClass(Session::class)]
final class SessionTest extends TestCase
{
#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function testSecure(): void
{
$_SESSION[' PMA_token '] = null;
$_SESSION[' HMAC_secret '] = null;

Session::secure();

/** @psalm-suppress TypeDoesNotContainType */
self::assertIsString($_SESSION[' PMA_token ']);
self::assertNotEmpty($_SESSION[' PMA_token ']);
/** @psalm-suppress TypeDoesNotContainType */
self::assertIsString($_SESSION[' HMAC_secret ']);
self::assertNotEmpty($_SESSION[' HMAC_secret ']);
}
}

0 comments on commit 70425ba

Please sign in to comment.