Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Upgraded PHPUnit, php 7.2 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kleijnweb committed Mar 6, 2018
1 parent 8b279ad commit 00c7c9b
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 34 deletions.
11 changes: 7 additions & 4 deletions composer.json
Expand Up @@ -12,11 +12,15 @@
"description": "Symfony JWT authentication with support for asymmetric keys and externally loaded secrets",
"autoload": {
"psr-4": {
"KleijnWeb\\JwtBundle\\Tests\\": "tests/unit",
"KleijnWeb\\JwtBundle\\Tests\\Functional\\": "tests/functional",
"KleijnWeb\\JwtBundle\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"KleijnWeb\\JwtBundle\\Tests\\": "tests/unit",
"KleijnWeb\\JwtBundle\\Tests\\Functional\\": "tests/functional"
}
},
"require": {
"php": "^7.0.0",
"symfony/dependency-injection": ">=2.8.7",
Expand All @@ -30,8 +34,7 @@
"symfony/security-bundle": ">=2.8.7"
},
"require-dev": {
"phpunit/phpunit": "^5.2",
"phpunit/phpunit-mock-objects": "^3.1",
"phpunit/phpunit": "^6.5",
"symfony/framework-bundle": ">=2.8.7",
"symfony/browser-kit": ">=2.8.7",
"symfony/form": ">=2.8.7",
Expand Down
2 changes: 1 addition & 1 deletion src/Jwt/JwtKey.php
Expand Up @@ -91,7 +91,7 @@ public function __construct(array $options)

$options = array_merge($defaults, $options);
$this->issuer = $options['issuer'];
$this->audience = $options['audience'];
$this->audience = is_array($options['audience']) ? $options['audience'] : [$options['audience']];
$this->type = $options['type'];
$this->minIssueTime = $options['minIssueTime'];
$this->requiredClaims = $options['require'];
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/App/app/TestKernel.php
Expand Up @@ -29,6 +29,6 @@ public function registerBundles()
*/
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__ . '/config_' . $this->getEnvironment() .'.yml');
$loader->load(__DIR__ . '/config_' . $this->getEnvironment() . '.yml');
}
}
35 changes: 21 additions & 14 deletions tests/functional/TestCacheSmashingPHPUnitListener.php
Expand Up @@ -8,61 +8,68 @@

namespace KleijnWeb\JwtBundle\Tests\Functional;

use PHPUnit_Framework_Test;
use PHPUnit_Framework_AssertionFailedError;
use Exception;
use PHPUnit_Framework_TestSuite;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;

class TestCacheSmashingPHPUnitListener implements \PHPUnit_Framework_TestListener
class TestCacheSmashingPHPUnitListener implements TestListener
{
const SUITE_NAME = 'Functional';

public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addError(Test $test, Exception $e, $time)
{
//NOOP
}

public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
public function addFailure(Test $test, AssertionFailedError $e, $time)
{
//NOOP
}

public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addIncompleteTest(Test $test, Exception $e, $time)
{
//NOOP
}

public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addRiskyTest(Test $test, Exception $e, $time)
{
//NOOP
}

public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addSkippedTest(Test $test, Exception $e, $time)
{
//NOOP
}

public function startTest(PHPUnit_Framework_Test $test)
public function addWarning(Test $test, Warning $e, $time)
{
//NOOP
}

public function endTest(PHPUnit_Framework_Test $test, $time)
public function startTest(Test $test)
{
//NOOP
}

public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
public function endTest(Test $test, $time)
{
//NOOP
}

public function startTestSuite(TestSuite $suite)
{
$this->smashIfFunctionalSuite($suite);
}

public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
public function endTestSuite(TestSuite $suite)
{
$this->smashIfFunctionalSuite($suite);
}

private function smashIfFunctionalSuite(PHPUnit_Framework_TestSuite $suite)
private function smashIfFunctionalSuite(TestSuite $suite)
{
if ($suite->getName() !== self::SUITE_NAME) {
return;
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Authentication/JwtAuthenticationProviderTest.php
Expand Up @@ -14,6 +14,7 @@
use KleijnWeb\JwtBundle\Jwt\JwtToken;
use KleijnWeb\JwtBundle\User\JwtUserProvider;
use KleijnWeb\JwtBundle\User\UnsafeGroupsUserInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
Expand All @@ -23,7 +24,7 @@
/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class JwtAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
class JwtAuthenticationProviderTest extends TestCase
{
const ISSUER = 'http://api.server1.com/oauth2/token';
const SECRET = 'A Pre-Shared Key';
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Firewall/JwtAuthenticationListenerTest.php
Expand Up @@ -10,6 +10,7 @@
use KleijnWeb\JwtBundle\Authentication\JwtAuthenticatedToken;
use KleijnWeb\JwtBundle\Authentication\JwtAuthenticationToken;
use KleijnWeb\JwtBundle\Firewall\JwtAuthenticationListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
Expand All @@ -19,7 +20,7 @@
/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class JwtAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
class JwtAuthenticationListenerTest extends TestCase
{
/**
* @var AuthenticationManagerInterface
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Jwt/DecoderTest.php
Expand Up @@ -8,11 +8,12 @@
namespace KleijnWeb\JwtBundle\Tests\Jwt;

use KleijnWeb\JwtBundle\Jwt\Decoder;
use PHPUnit\Framework\TestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class DecoderTest extends \PHPUnit_Framework_TestCase
class DecoderTest extends TestCase
{
/**
* @test
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Jwt/EncoderTest.php
Expand Up @@ -8,11 +8,12 @@
namespace KleijnWeb\JwtBundle\Tests\Jwt;

use KleijnWeb\JwtBundle\Jwt\Encoder;
use PHPUnit\Framework\TestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class EncoderTest extends \PHPUnit_Framework_TestCase
class EncoderTest extends TestCase
{
/**
* @param string $data
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Jwt/JwtKeyTest.php
Expand Up @@ -14,11 +14,12 @@
use KleijnWeb\JwtBundle\Jwt\SecretLoader;
use KleijnWeb\JwtBundle\Jwt\SignatureValidator\HmacValidator;
use KleijnWeb\JwtBundle\Jwt\SignatureValidator\RsaValidator;
use PHPUnit\Framework\TestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class JwtKeyTest extends \PHPUnit_Framework_TestCase
class JwtKeyTest extends TestCase
{
/**
* @test
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Jwt/JwtTokenTest.php
Expand Up @@ -9,11 +9,12 @@

use KleijnWeb\JwtBundle\Jwt\JwtToken;
use KleijnWeb\JwtBundle\Jwt\SignatureValidator\SignatureValidator;
use PHPUnit\Framework\TestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class JwtTokenTest extends \PHPUnit_Framework_TestCase
class JwtTokenTest extends TestCase
{
// @codingStandardsIgnoreStart
const EXAMPLE_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ';
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Jwt/SignatureValidator/HmacValidatorTest.php
Expand Up @@ -9,11 +9,12 @@
namespace KleijnWeb\JwtBundle\Tests\Jwt\SignatureValidator;

use KleijnWeb\JwtBundle\Jwt\SignatureValidator\HmacValidator;
use PHPUnit\Framework\TestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class HmacValidatorTest extends \PHPUnit_Framework_TestCase
class HmacValidatorTest extends TestCase
{
/**
* @var string
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/Jwt/SignatureValidator/RsaValidatorTest.php
Expand Up @@ -9,11 +9,12 @@
namespace KleijnWeb\JwtBundle\Tests\Jwt\SignatureValidator;

use KleijnWeb\JwtBundle\Jwt\SignatureValidator\RsaValidator;
use PHPUnit\Framework\TestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class RsaValidatorTest extends \PHPUnit_Framework_TestCase
class RsaValidatorTest extends TestCase
{
/**
* @var string
Expand All @@ -27,6 +28,7 @@ class RsaValidatorTest extends \PHPUnit_Framework_TestCase
m6IDw3fRhZQrVwZ816/eN+1sqpIMZF4oo4kRA4b64U04ex67A/6BwDDQ3LH0mD4d
EwIDAQAB
-----END PUBLIC KEY-----';

/**
* @var string
*/
Expand Down Expand Up @@ -81,21 +83,21 @@ public static function testSetProvider()
{
// SHA256

$payload1 = 'some payload';
$payload1 = 'some payload';
$signature1 = '';
openssl_sign($payload1, $signature1, self::$privKey, RsaValidator::SHA256);

$payload2 = 'some other payload';
$payload2 = 'some other payload';
$signature2 = '';
openssl_sign($payload2, $signature2, self::$privKey, RsaValidator::SHA256);

// SHA512

$payload3 = 'some payload';
$payload3 = 'some payload';
$signature3 = '';
openssl_sign($payload3, $signature3, self::$privKey, RsaValidator::SHA512);

$payload4 = 'some other payload';
$payload4 = 'some other payload';
$signature4 = '';
openssl_sign($payload4, $signature4, self::$privKey, RsaValidator::SHA512);

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/User/JwtUserProviderTest.php
Expand Up @@ -8,14 +8,15 @@
namespace KleijnWeb\JwtBundle\Tests\User;

use KleijnWeb\JwtBundle\Jwt\JwtToken;
use KleijnWeb\JwtBundle\User\JwtUserProvider;
use KleijnWeb\JwtBundle\User\JwtUser;
use KleijnWeb\JwtBundle\User\JwtUserProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class JwtUserProviderTest extends \PHPUnit_Framework_TestCase
class JwtUserProviderTest extends TestCase
{
/**
* @var JwtUserProvider
Expand Down

0 comments on commit 00c7c9b

Please sign in to comment.