CookieTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Utils;
  4. use PHPUnit\Framework\TestCase;
  5. final class CookieTest extends TestCase
  6. {
  7. /**
  8. * @covers App\Utils\Cookie::set
  9. */
  10. public function testSet(): void
  11. {
  12. $data = ['testKey' => 'testValue'];
  13. $time = time() + 3600;
  14. Cookie::set($data, $time);
  15. $this->assertEquals('testValue', $_COOKIE['testKey']);
  16. }
  17. /**
  18. * @covers App\Utils\Cookie::setWithDomain
  19. */
  20. public function testSetWithDomain(): void
  21. {
  22. $data = ['testKey' => 'testValue'];
  23. $time = time() + 3600;
  24. $domain = 'localhost';
  25. Cookie::setWithDomain($data, $time, $domain);
  26. $this->assertEquals('testValue', $_COOKIE['testKey']);
  27. }
  28. /**
  29. * @covers App\Utils\Cookie::get
  30. */
  31. public function testGet(): void
  32. {
  33. $data = ['testKey' => 'testValue'];
  34. $time = time() + 3600;
  35. Cookie::set($data, $time);
  36. $this->assertEquals('testValue', Cookie::get('testKey'));
  37. }
  38. }