fuc-new/tests/App/Utils/CookieTest.php
hellcat 1fe8673f62 1
2025-10-01 13:34:29 +08:00

52 lines
1.0 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace App\Utils;
use PHPUnit\Framework\TestCase;
use App\Utils\Cookie;
final class CookieTest extends TestCase
{
/**
* @covers App\Utils\Cookie::set
*/
public function testSet(): void
{
$data = ['testKey' => 'testValue'];
$time = time() + 3600;
Cookie::set($data, $time);
$this->assertEquals('testValue', $_COOKIE['testKey']);
}
/**
* @covers App\Utils\Cookie::setWithDomain
*/
public function testSetWithDomain(): void
{
$data = ['testKey' => 'testValue'];
$time = time() + 3600;
$domain = 'localhost';
Cookie::setWithDomain($data, $time, $domain);
$this->assertEquals('testValue', $_COOKIE['testKey']);
}
/**
* @covers App\Utils\Cookie::get
*/
public function testGet(): void
{
$data = ['testKey' => 'testValue'];
$time = time() + 3600;
Cookie::set($data, $time);
$this->assertEquals('testValue', Cookie::get('testKey'));
}
}