for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Guarded Authentication package.
*
* (c) Jafar Jabr <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Jafar\Bundle\GuardedAuthenticationBundle\Tests\Api\JWSExtractor;
use Jafar\Bundle\GuardedAuthenticationBundle\Api\JWSExtractor\TokenExtractor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* Class TokenExtractorTest.
* @author Jafar Jabr <[email protected]>
final class TokenExtractorTest extends TestCase
{
* test getRequestToken.
public function testGetTokenRequest()
$extractor = new TokenExtractor('Bearer', 'Authorization');
$request = new Request();
$this->assertFalse($extractor->extract($request));
$request->headers->set('Authorization', 'Bear testToken');
$request->headers->set('not Authorization', 'Bearer testToken');
$request->headers->set('Authorization', 'Bearer testToken');
$this->assertEquals('testToken', $extractor->extract($request));
}