Skip to content

Commit 03f728f

Browse files
authored
Merge pull request #99 from chrisryan/master
Add Support for PHP 8.
2 parents cf844d7 + 18c3c8e commit 03f728f

File tree

4 files changed

+49
-48
lines changed

4 files changed

+49
-48
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-18.04
1212
strategy:
1313
matrix:
14-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
14+
php-versions: ['7.3', '7.4', '8.0', '8.1']
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
},
3030
"license": "MIT",
3131
"require": {
32-
"php": "^7.0",
33-
"traderinteractive/exceptions": "^1.2",
34-
"traderinteractive/filter-arrays": "^3.2",
35-
"traderinteractive/filter-bools": "^3.0",
36-
"traderinteractive/filter-dates": "^3.1",
37-
"traderinteractive/filter-floats": "^3.0",
38-
"traderinteractive/filter-ints": "^3.0",
39-
"traderinteractive/filter-strings": "^3.5"
32+
"php": "^7.3 || ^8.0",
33+
"traderinteractive/exceptions": "^2.0",
34+
"traderinteractive/filter-arrays": "^4.0",
35+
"traderinteractive/filter-bools": "^4.0",
36+
"traderinteractive/filter-dates": "^4.0",
37+
"traderinteractive/filter-floats": "^4.0",
38+
"traderinteractive/filter-ints": "^4.0",
39+
"traderinteractive/filter-strings": "^4.0"
4040
},
4141
"require-dev": {
42-
"phpunit/phpunit": "^6.0",
42+
"phpunit/phpunit": "^9.0",
4343
"squizlabs/php_codesniffer": "^3.2",
4444
"symfony/yaml": "^3.4"
4545
},

phpunit.xml.dist

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<phpunit colors="true" forceCoversAnnotation="true">
2-
<testsuite name="Unit Tests">
3-
<directory>./tests</directory>
4-
</testsuite>
5-
<filter>
6-
<whitelist>
7-
<directory>src</directory>
8-
</whitelist>
9-
</filter>
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" forceCoversAnnotation="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory>src</directory>
6+
</include>
7+
</coverage>
8+
<testsuite name="Unit Tests">
9+
<directory>./tests</directory>
10+
</testsuite>
1011
</phpunit>

tests/FiltererTest.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class FiltererTest extends TestCase
4444
. "</books>\n"
4545
);
4646

47-
public function setUp()
47+
public function setUp(): void
4848
{
4949
Filterer::setFilterAliases(Filterer::DEFAULT_FILTER_ALIASES);
5050
}
@@ -690,35 +690,35 @@ public function setBadFilterAliases()
690690
* @test
691691
* @covers ::filter
692692
* @covers ::execute
693-
* @expectedException Exception
694-
* @expectedExceptionMessage Function 'boo' for field 'foo' is not callable
695693
*/
696694
public function notCallable()
697695
{
696+
$this->expectException(Exception::class);
697+
$this->expectExceptionMessage("Function 'boo' for field 'foo' is not callable");
698698
Filterer::filter(['foo' => [['boo']]], ['foo' => 0]);
699699
}
700700

701701
/**
702702
* @test
703703
* @covers ::filter
704704
* @covers ::execute
705-
* @expectedException InvalidArgumentException
706-
* @expectedExceptionMessage 'allowUnknowns' option was not a bool
707705
*/
708706
public function allowUnknownsNotBool()
709707
{
708+
$this->expectException(InvalidArgumentException::class);
709+
$this->expectExceptionMessage("'allowUnknowns' option was not a bool");
710710
Filterer::filter([], [], ['allowUnknowns' => 1]);
711711
}
712712

713713
/**
714714
* @test
715715
* @covers ::filter
716716
* @covers ::execute
717-
* @expectedException InvalidArgumentException
718-
* @expectedExceptionMessage 'defaultRequired' option was not a bool
719717
*/
720718
public function defaultRequiredNotBool()
721719
{
720+
$this->expectException(InvalidArgumentException::class);
721+
$this->expectExceptionMessage("'defaultRequired' option was not a bool");
722722
Filterer::filter([], [], ['defaultRequired' => 1]);
723723
}
724724

@@ -739,69 +739,69 @@ public function filterThrowsExceptionOnInvalidResponseType()
739739
* @test
740740
* @covers ::filter
741741
* @covers ::execute
742-
* @expectedException InvalidArgumentException
743-
* @expectedExceptionMessage filters for field 'boo' was not a array
744742
*/
745743
public function filtersNotArrayInLeftOverSpec()
746744
{
745+
$this->expectException(InvalidArgumentException::class);
746+
$this->expectExceptionMessage("filters for field 'boo' was not a array");
747747
Filterer::filter(['boo' => 1], []);
748748
}
749749

750750
/**
751751
* @test
752752
* @covers ::filter
753753
* @covers ::execute
754-
* @expectedException InvalidArgumentException
755-
* @expectedExceptionMessage filters for field 'boo' was not a array
756754
*/
757755
public function filtersNotArrayWithInput()
758756
{
757+
$this->expectException(InvalidArgumentException::class);
758+
$this->expectExceptionMessage("filters for field 'boo' was not a array");
759759
Filterer::filter(['boo' => 1], ['boo' => 'notUnderTest']);
760760
}
761761

762762
/**
763763
* @test
764764
* @covers ::filter
765765
* @covers ::execute
766-
* @expectedException InvalidArgumentException
767-
* @expectedExceptionMessage filter for field 'boo' was not a array
768766
*/
769767
public function filterNotArray()
770768
{
769+
$this->expectException(InvalidArgumentException::class);
770+
$this->expectExceptionMessage("filter for field 'boo' was not a array");
771771
Filterer::filter(['boo' => [1]], ['boo' => 'notUnderTest']);
772772
}
773773

774774
/**
775775
* @test
776776
* @covers ::filter
777777
* @covers ::execute
778-
* @expectedException InvalidArgumentException
779-
* @expectedExceptionMessage 'required' for field 'boo' was not a bool
780778
*/
781779
public function requiredNotBool()
782780
{
781+
$this->expectException(InvalidArgumentException::class);
782+
$this->expectExceptionMessage("'required' for field 'boo' was not a bool");
783783
Filterer::filter(['boo' => ['required' => 1]], []);
784784
}
785785

786786
/**
787787
* @test
788788
* @covers ::registerAlias
789-
* @expectedException InvalidArgumentException
790-
* @expectedExceptionMessage $alias was not a string or int
791789
*/
792790
public function registerAliasAliasNotString()
793791
{
792+
$this->expectException(InvalidArgumentException::class);
793+
$this->expectExceptionMessage('$alias was not a string or int');
794794
Filterer::registerAlias(true, 'strtolower');
795795
}
796796

797797
/**
798798
* @test
799799
* @covers ::registerAlias
800-
* @expectedException Exception
801-
* @expectedExceptionMessage Alias 'upper' exists
802800
*/
803801
public function registerExistingAliasOverwriteFalse()
804802
{
803+
$this->expectException(Exception::class);
804+
$this->expectExceptionMessage("Alias 'upper' exists");
805805
Filterer::setFilterAliases([]);
806806
Filterer::registerAlias('upper', 'strtoupper');
807807
Filterer::registerAlias('upper', 'strtoupper', false);
@@ -834,13 +834,13 @@ public static function passingFilter($value)
834834
* @test
835835
* @covers ::filter
836836
* @covers ::execute
837-
* @expectedException InvalidArgumentException
838-
* @expectedExceptionMessage error for field 'fieldOne' was not a non-empty string
839837
*
840838
* @return void
841839
*/
842840
public function filterWithNonStringError()
843841
{
842+
$this->expectException(InvalidArgumentException::class);
843+
$this->expectExceptionMessage("error for field 'fieldOne' was not a non-empty string");
844844
Filterer::filter(
845845
['fieldOne' => [['strtoupper'], 'error' => new stdClass()]],
846846
['fieldOne' => 'valueOne']
@@ -853,13 +853,13 @@ public function filterWithNonStringError()
853853
* @test
854854
* @covers ::filter
855855
* @covers ::execute
856-
* @expectedException InvalidArgumentException
857-
* @expectedExceptionMessage error for field 'fieldOne' was not a non-empty string
858856
*
859857
* @return void
860858
*/
861859
public function filterWithEmptyStringError()
862860
{
861+
$this->expectException(InvalidArgumentException::class);
862+
$this->expectExceptionMessage("error for field 'fieldOne' was not a non-empty string");
863863
Filterer::filter(
864864
['fieldOne' => [['strtoupper'], 'error' => "\n \t"]],
865865
['fieldOne' => 'valueOne']
@@ -907,9 +907,9 @@ public function ofScalarsFail()
907907
Field '1' with value 'array (
908908
)' failed filtering, message 'Value 'array (
909909
)' is not a string'
910-
Field '2' with value 'stdClass::__set_state(array(
911-
))' failed filtering, message 'Value 'stdClass::__set_state(array(
912-
))' is not a string'
910+
Field '2' with value '(object) array(
911+
)' failed filtering, message 'Value '(object) array(
912+
)' is not a string'
913913
TXT;
914914
$this->assertSame($expected, $e->getMessage());
915915
}
@@ -965,9 +965,9 @@ public function ofArraysFail()
965965
$this->fail();
966966
} catch (FilterException $e) {
967967
$expected = <<<TXT
968-
Field 'key' with value 'stdClass::__set_state(array(
969-
))' failed filtering, message 'Value 'stdClass::__set_state(array(
970-
))' is not a string'
968+
Field 'key' with value '(object) array(
969+
)' failed filtering, message 'Value '(object) array(
970+
)' is not a string'
971971
Field 'key' with value 'array (
972972
)' failed filtering, message 'Value 'array (
973973
)' is not a string'

0 commit comments

Comments
 (0)