Skip to content

Commit

Permalink
Merge pull request #25 from lukasoppermann/fix-phpunit
Browse files Browse the repository at this point in the history
Upgrade to phpunit 9 & drop support for < php 7.3
  • Loading branch information
lukasoppermann authored Nov 4, 2020
2 parents fdf78f9 + 6a6d887 commit 388b71d
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .php_cs.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"php":"7.3.11","version":"2.16.4:v2.16.4#1023c3458137ab052f6ff1e09621a721bfdeca13","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"none"}},"hashes":{"src\/Httpstatus.php":2174810979,"src\/Httpstatuscodes.php":2078825867,"tests\/HttpstatuscodesTest.php":4152359845,"tests\/HttpstatusTest.php":3909827068}}
{"php":"7.3.11","version":"2.16.7:v2.16.7#4e35806a6d7d8510d6842ae932e8832363d22c87","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"none"}},"hashes":{"src\/Httpstatus.php":2174810979,"src\/Httpstatuscodes.php":2078825867,"tests\/HttpstatuscodesTest.php":2890212170}}
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":6609:{a:2:{s:7:"defects";a:25:{s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #0";i:4;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #1";i:4;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #2";i:4;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #3";i:4;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #4";i:4;s:98:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidReasonPhraseWithCarriageReturnCharacter";i:4;s:72:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testNonExistentIndexCode";i:4;s:68:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidIndexCode";i:4;s:90:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "string"";i:4;s:89:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "array"";i:4;s:88:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "bool"";i:4;s:93:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "min range"";i:4;s:93:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "max range"";i:4;s:99:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "standard Object"";i:4;s:68:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidIndexText";i:4;s:83:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "int"";i:4;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "array"";i:4;s:84:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "bool"";i:4;s:95:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "standard Object"";i:4;s:80:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidConstructorCollection";i:4;s:7:"Warning";i:6;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #0";i:4;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #1";i:4;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #2";i:4;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #3";i:4;}s:5:"times";a:44:{s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #0";d:0.003;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #1";d:0;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #2";d:0;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #3";d:0;s:87:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidCustomTexts with data set #4";d:0;s:61:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testCountable";d:0;s:69:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testIteratorAggregate";d:0;s:65:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetStatusText";d:0;s:65:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetStatusCode";d:0.001;s:80:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetStatusCodeCaseInsensitive";d:0.001;s:71:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetStatusTextCustom";d:0;s:98:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidReasonPhraseWithCarriageReturnCharacter";d:0;s:72:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testNonExistentIndexCode";d:0;s:68:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidIndexCode";d:0;s:90:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "string"";d:0;s:89:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "array"";d:0;s:88:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "bool"";d:0;s:93:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "min range"";d:0;s:93:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "max range"";d:0;s:99:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidTypeCode with data set "standard Object"";d:0;s:68:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidIndexText";d:0;s:83:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "int"";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "array"";d:0;s:84:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "bool"";d:0;s:95:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidText with data set "standard Object"";d:0;s:80:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testInvalidConstructorCollection";d:0;s:65:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testHasStatusCode";d:0;s:67:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testHasReasonPhrase";d:0.001;s:7:"Warning";d:0;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #0";d:0;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #1";d:0;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #2";d:0;s:100:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClassForInvalidCodes with data set #3";d:0;s:66:"Lukasoppermann\Httpstatus\tests\HttpstatuscodesTest::testConstants";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #0";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #1";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #2";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #3";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #4";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #5";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #6";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #7";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #8";d:0;s:85:"Lukasoppermann\Httpstatus\tests\HttpstatusTest::testGetResponseClass with data set #9";d:0;}}}
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ sudo: false

matrix:
include:
- php: 5.6
env:
- EXECUTE_CS_CHECK=true
- EXECUTE_COVERAGE=true
- php: 7.2
- php: 7.3
- php: 7.4
env:
- EXECUTE_CS_CHECK=true
- EXECUTE_COVERAGE=true
fast_finish: true

cache:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"php" : ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit" : "~4.0",
"phpunit/phpunit" : "~9.0",
"league/csv": "^7.1",
"friendsofphp/php-cs-fixer": "^2.16",
"php-coveralls/php-coveralls": "^2.4"
Expand Down
50 changes: 21 additions & 29 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Httpstatus-php Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Httpstatus-php Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
</phpunit>
31 changes: 31 additions & 0 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Httpstatus-php Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>
</phpunit>
20 changes: 16 additions & 4 deletions tests/HttpstatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@

use League\Csv\Reader;
use Lukasoppermann\Httpstatus\Httpstatus;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
use OutOfBoundsException;
use RuntimeException;

/**
* @group formatter
*/
class HttpstatusTest extends PHPUnit_Framework_TestCase
class HttpstatusTest extends TestCase
{
protected $statuses;

protected $httpStatus;

public function setUp()
public function setUp(): void
{
// This file is from https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv
// It is a csv of all http codes & texts used for testing here
Expand Down Expand Up @@ -43,6 +46,7 @@ public function setUp()
*/
public function testInvalidCustomTexts($statusArray)
{
$this->expectException(RuntimeException::class);
(new Httpstatus($statusArray));
}

Expand Down Expand Up @@ -139,6 +143,7 @@ public function testGetStatusTextCustom()
*/
public function testInvalidReasonPhraseWithCarriageReturnCharacter()
{
$this->expectException(InvalidArgumentException::class);
$reasonPhrase = 'Hello There'.PHP_EOL.'How Are you!!';
(new Httpstatus())->mergeHttpStatus(404, $reasonPhrase);
}
Expand All @@ -149,6 +154,7 @@ public function testInvalidReasonPhraseWithCarriageReturnCharacter()
*/
public function testNonExistentIndexCode()
{
$this->expectException(OutOfBoundsException::class);
(new Httpstatus())->getReasonPhrase(499);
}

Expand All @@ -158,6 +164,7 @@ public function testNonExistentIndexCode()
*/
public function testInvalidIndexCode()
{
$this->expectException(InvalidArgumentException::class);
(new Httpstatus())->getReasonPhrase(600);
}

Expand All @@ -168,6 +175,7 @@ public function testInvalidIndexCode()
*/
public function testInvalidTypeCode($code)
{
$this->expectException(InvalidArgumentException::class);
(new Httpstatus())->getReasonPhrase($code);
}

Expand All @@ -189,6 +197,7 @@ public function invalidStatusCode()
*/
public function testInvalidIndexText()
{
$this->expectException(OutOfBoundsException::class);
(new Httpstatus())->getStatusCode('I am a Teapot.');
}

Expand All @@ -199,6 +208,7 @@ public function testInvalidIndexText()
*/
public function testInvalidText($text)
{
$this->expectException(InvalidArgumentException::class);
(new Httpstatus())->getStatusCode($text);
}

Expand All @@ -218,6 +228,7 @@ public function invalidReasonPhrase()
*/
public function testInvalidConstructorCollection()
{
$this->expectException(InvalidArgumentException::class);
new Httpstatus('yo');
}

Expand Down Expand Up @@ -271,7 +282,7 @@ public function testGetResponseClass($expectedClass, $statusCode)
*/
public function responseClasses()
{
$Httpstatuscodes = $this->getMock('Lukasoppermann\Httpstatus\Httpstatuscodes');
$Httpstatuscodes = $this->createMock('Lukasoppermann\Httpstatus\Httpstatuscodes');

return [
[Httpstatus::CLASS_INFORMATIONAL, $Httpstatuscodes::HTTP_CONTINUE],
Expand All @@ -293,6 +304,7 @@ public function responseClasses()
*/
public function testGetResponseClassForInvalidCodes($statusCode)
{
$this->expectException(InvalidArgumentException::class);
$this->httpStatus->getResponseClass($statusCode);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/HttpstatuscodesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
namespace Lukasoppermann\Httpstatus\tests;

use League\Csv\Reader;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* @group formatter
*/
class HttpstatuscodesTest extends PHPUnit_Framework_TestCase
class HttpstatuscodesTest extends TestCase
{
protected $statuses;

public function setUp()
public function setUp(): void
{
// This file is from https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv
// It is a csv of all http codes & texts used for testing here
Expand Down

0 comments on commit 388b71d

Please sign in to comment.