mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-17 04:15:15 +02:00
Add more Cookie tests (create new StaticCookie class for mocking setcookie())
This commit is contained in:
parent
a8b89dc486
commit
94a8a60841
4 changed files with 182 additions and 17 deletions
28
tests/Util/StaticCookie.php
Normal file
28
tests/Util/StaticCookie.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\Util;
|
||||
|
||||
use Friendica\Model\User\Cookie;
|
||||
|
||||
/**
|
||||
* Overrides the Cookie class so all cookie information will be saved to a static public variable
|
||||
*/
|
||||
class StaticCookie extends Cookie
|
||||
{
|
||||
/** @var array static Cookie array mock */
|
||||
public static $_COOKIE = [];
|
||||
/** @var int The last expire time set */
|
||||
public static $_EXPIRE;
|
||||
|
||||
protected function setCookie(string $name, string $value = null, int $expire = null, bool $secure = null)
|
||||
{
|
||||
self::$_COOKIE[$name] = $value;
|
||||
self::$_EXPIRE = $expire;
|
||||
}
|
||||
|
||||
public static function clearStatic()
|
||||
{
|
||||
self::$_EXPIRE = null;
|
||||
self::$_COOKIE = [];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue