CacheTokenVerifier example

namespace Symfony\Component\Security\Core\Tests\Authentication\RememberMe;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Security\Core\Authentication\RememberMe\CacheTokenVerifier;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;

class CacheTokenVerifierTest extends TestCase
{
    public function testVerifyCurrentToken()
    {
        $verifier = new CacheTokenVerifier(new ArrayAdapter());
        $token = new PersistentToken('class', 'user', 'series1@special:chars=/', 'value', new \DateTimeImmutable());
        $this->assertTrue($verifier->verifyToken($token, 'value'));
    }

    public function testVerifyFailsInvalidToken()
    {
        $verifier = new CacheTokenVerifier(new ArrayAdapter());
        $token = new PersistentToken('class', 'user', 'series1@special:chars=/', 'value', new \DateTimeImmutable());
        $this->assertFalse($verifier->verifyToken($token, 'wrong-value'));
    }

    
Home | Imprint | This part of the site doesn't use cookies.