Skip to content

Commit

Permalink
Merge pull request #129 from akrabat/php8
Browse files Browse the repository at this point in the history
Support PHP 8 and remove 7.1 and 7.2
  • Loading branch information
l0gicgate committed Jan 18, 2021
2 parents fd03c9e + ea2eb7b commit 2c2949d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
composer.lock
vendor
coverage
/.phpunit.result.cache
/phpunit.xml
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: php

dist: trusty
dist: focal

matrix:
include:
- php: 7.1
- php: 7.2
- php: 7.3
dist: xenial
- php: 7.4
- php: 8.0
env: ANALYSIS='true'
- php: nightly

Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
"homepage": "http://joshlockhart.com"
}
],
"config": {
"sort-packages": true
},
"require": {
"php": "^7.1",
"php": "^7.3|^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"phpspec/prophecy": "^1.10",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.5.8"
},
"autoload": {
Expand Down
21 changes: 12 additions & 9 deletions tests/GuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Exception;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -24,26 +25,28 @@

class GuardTest extends TestCase
{
/**
* @expectedException Exception
* @expectedExceptionMessage CSRF middleware instantiation failed. Minimum strength is 16.
*/
use ProphecyTrait;

public function testStrengthLowerThan16ThrowsException()
{
$storage = [];
$responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);
$mw = new Guard($responseFactoryProphecy->reveal(), 'test', $storage, null, 200, 15);

$this->expectException(Exception::class);
$this->expectExceptionMessage('CSRF middleware instantiation failed. Minimum strength is 16.');
new Guard($responseFactoryProphecy->reveal(), 'test', $storage, null, 200, 15);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage Invalid CSRF storage.
* Use session_start() before instantiating the Guard middleware or provide array storage.
*/
public function testSetStorageThrowsExceptionWhenFallingBackOnSessionThatHasNotBeenStarted()
{
$responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);
$mw = new Guard($responseFactoryProphecy->reveal(), 'test');

$this->expectException(Exception::class);
$this->expectExceptionMessage('Invalid CSRF storage.');
new Guard($responseFactoryProphecy->reveal(), 'test');
}

/**
Expand All @@ -53,7 +56,7 @@ public function testSetStorageSetsKeysOnSessionObjectWhenNotExist()
{
session_start();
$responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);
$mw = new Guard($responseFactoryProphecy->reveal(), 'test');
new Guard($responseFactoryProphecy->reveal(), 'test');

$this->assertArrayHasKey('test', $_SESSION);
}
Expand Down

0 comments on commit 2c2949d

Please sign in to comment.