Skip to content

Commit 7e4692e

Browse files
authored
feat: php 8 support (#96)
- updates php requirement to `^7.3 || ^8.0` - updates phpunit to ^9.5 - adds prophecy-phpunit - updates phpstan to ^0.12 Fixes #92
1 parent b46c6a0 commit 7e4692e

File tree

8 files changed

+33
-15
lines changed

8 files changed

+33
-15
lines changed

.github/workflows/phpunit.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- "master"
7+
- "main"
88

99
jobs:
1010
phpunit:
@@ -20,6 +20,7 @@ jobs:
2020
php-version:
2121
- "7.3"
2222
- "7.4"
23+
- "8.0"
2324
operating-system:
2425
- "ubuntu-latest"
2526

@@ -45,15 +46,15 @@ jobs:
4546

4647
- name: "Install lowest dependencies"
4748
if: ${{ matrix.dependencies == 'lowest' }}
48-
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
49+
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest --ignore-platform-reqs"
4950

5051
- name: "Install highest dependencies"
5152
if: ${{ matrix.dependencies == 'highest' }}
52-
run: "composer update --no-interaction --no-progress --no-suggest"
53+
run: "composer update --no-interaction --no-progress --no-suggest --ignore-platform-reqs"
5354

5455
- name: "Install locked dependencies"
5556
if: ${{ matrix.dependencies == 'locked' }}
56-
run: "composer install --no-interaction --no-progress --no-suggest"
57+
run: "composer install --no-interaction --no-progress --no-suggest --ignore-platform-reqs"
5758

5859
- name: "Tests"
5960
run: "vendor/bin/phpunit"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.phpunit.result.cache
12
clover.xml
23
composer.lock
34
phpunit.xml

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.1",
14+
"php": "^7.3 || ^8.0",
1515
"ext-dom": "*",
1616
"ext-libxml": "*",
1717
"psr/container": "^1.0",
1818
"psr/http-message": "^1.0",
19-
"laminas/laminas-filter": "^2.7.2",
19+
"laminas/laminas-filter": "^2.9",
2020
"laminas/laminas-i18n": "^2.7",
21-
"laminas/laminas-inputfilter": "^2.8.1",
22-
"laminas/laminas-servicemanager": "^3.0",
21+
"laminas/laminas-inputfilter": "^2.8",
22+
"laminas/laminas-servicemanager": "^3.5",
2323
"laminas/laminas-stdlib": "^3.0",
2424
"laminas/laminas-uri": "^2.5",
25-
"laminas/laminas-validator": "^2.10.2"
25+
"laminas/laminas-validator": "^2.13"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^7.0",
28+
"phpunit/phpunit": "^9.5",
2929
"squizlabs/php_codesniffer": "^3.0",
30-
"phpstan/phpstan": "^0.10"
30+
"phpstan/phpstan": "^0.12",
31+
"phpspec/prophecy-phpunit": "^2.0"
3132
},
3233
"suggest": {
3334
"laminas/laminas-servicemanager": "To support third-party validators and filters"

test/FormElement/BaseFormElementTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
use DOMDocument;
88
use DOMElement;
99
use PHPUnit\Framework\TestCase;
10+
use Prophecy\PhpUnit\ProphecyTrait;
1011
use ReflectionMethod;
1112
use Xtreamwayz\HTMLFormValidator\FormElement\Text;
1213
use function iterator_to_array;
1314

1415
class BaseFormElementTest extends TestCase
1516
{
17+
use ProphecyTrait;
18+
1619
public function dataAttributesProvider()
1720
{
1821
return [

test/FormElementArraytest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace XtreamwayzTest\HTMLFormValidator;
66

77
use PHPUnit\Framework\TestCase;
8+
use Prophecy\PhpUnit\ProphecyTrait;
89
use Psr\Http\Message\ServerRequestInterface;
910
use Xtreamwayz\HTMLFormValidator\FormFactory;
1011
use Xtreamwayz\HTMLFormValidator\ValidationResult;
@@ -15,6 +16,8 @@
1516

1617
class FormElementArraytest extends TestCase
1718
{
19+
use ProphecyTrait;
20+
1821
public function testCheckboxArrayIsValid() : void
1922
{
2023
$html = '

test/FormFactoryFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
use Xtreamwayz\HTMLFormValidator\FormFactoryFactory;
1111
use Xtreamwayz\HTMLFormValidator\FormFactoryInterface;
1212
use Laminas\InputFilter\Factory;
13+
use Prophecy\PhpUnit\ProphecyTrait;
1314

1415
class FormFactoryFactoryTest extends TestCase
1516
{
17+
use ProphecyTrait;
18+
1619
/** @var ContainerInterface|ProphecyInterface */
1720
private $container;
1821

test/FormFactoryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
use Xtreamwayz\HTMLFormValidator\FormInterface;
1313
use Laminas\InputFilter\Factory;
1414
use Laminas\InputFilter\InputFilterInterface;
15+
use Prophecy\PhpUnit\ProphecyTrait;
1516

1617
class FormFactoryTest extends TestCase
1718
{
19+
use ProphecyTrait;
20+
1821
public function testConstructorWithNoArguments() : void
1922
{
2023
$formFactory = new FormFactory();

test/FormTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
namespace XtreamwayzTest\HTMLFormValidator;
66

77
use PHPUnit\Framework\TestCase;
8+
use Prophecy\PhpUnit\ProphecyTrait;
89
use Psr\Http\Message\ServerRequestInterface;
910
use Xtreamwayz\HTMLFormValidator\FormFactory;
1011
use Xtreamwayz\HTMLFormValidator\ValidationResult;
1112

1213
class FormTest extends TestCase
1314
{
15+
use ProphecyTrait;
16+
1417
private $rawValues = [
1518
'foo' => 'bar',
1619
'baz' => ' qux ',
@@ -104,8 +107,8 @@ public function testSetValuesStatically() : void
104107
'baz' => 'qux',
105108
]);
106109

107-
self::assertContains('<input type="text" name="foo" value="bar">', $form->asString());
108-
self::assertContains('<input type="text" name="baz" value="qux">', $form->asString());
110+
self::assertStringContainsString('<input type="text" name="foo" value="bar">', $form->asString());
111+
self::assertStringContainsString('<input type="text" name="baz" value="qux">', $form->asString());
109112
}
110113

111114
public function testSetValuesWithConstructor() : void
@@ -121,7 +124,7 @@ public function testSetValuesWithConstructor() : void
121124
'baz' => 'qux',
122125
]);
123126

124-
self::assertContains('<input type="text" name="foo" value="bar">', $form->asString());
125-
self::assertContains('<input type="text" name="baz" value="qux">', $form->asString());
127+
self::assertStringContainsString('<input type="text" name="foo" value="bar">', $form->asString());
128+
self::assertStringContainsString('<input type="text" name="baz" value="qux">', $form->asString());
126129
}
127130
}

0 commit comments

Comments
 (0)