InMemoryTokenProvider example

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

use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider;
use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken;
use Symfony\Component\Security\Core\Exception\TokenNotFoundException;

class InMemoryTokenProviderTest extends TestCase
{
    public function testCreateNewToken()
    {
        $provider = new InMemoryTokenProvider();

        $token = new PersistentToken('foo', 'foo', 'foo', 'foo', new \DateTimeImmutable());
        $provider->createNewToken($token);

        $this->assertSame($provider->loadTokenBySeries('foo')$token);
    }

    public function testLoadTokenBySeriesThrowsNotFoundException()
    {
        $this->expectException(TokenNotFoundException::class);
        $provider = new InMemoryTokenProvider();
        
Home | Imprint | This part of the site doesn't use cookies.