Skip to content

Commit

Permalink
feat: php 8 support (#96)
Browse files Browse the repository at this point in the history
- updates php requirement to `^7.3 || ^8.0`
- updates phpunit to ^9.5
- adds prophecy-phpunit
- updates phpstan to ^0.12

Fixes #92
  • Loading branch information
geerteltink committed Dec 26, 2020
1 parent b46c6a0 commit 7e4692e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- "master"
- "main"

jobs:
phpunit:
Expand All @@ -20,6 +20,7 @@ jobs:
php-version:
- "7.3"
- "7.4"
- "8.0"
operating-system:
- "ubuntu-latest"

Expand All @@ -45,15 +46,15 @@ jobs:

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

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

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

- name: "Tests"
run: "vendor/bin/phpunit"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit.result.cache
clover.xml
composer.lock
phpunit.xml
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.3 || ^8.0",
"ext-dom": "*",
"ext-libxml": "*",
"psr/container": "^1.0",
"psr/http-message": "^1.0",
"laminas/laminas-filter": "^2.7.2",
"laminas/laminas-filter": "^2.9",
"laminas/laminas-i18n": "^2.7",
"laminas/laminas-inputfilter": "^2.8.1",
"laminas/laminas-servicemanager": "^3.0",
"laminas/laminas-inputfilter": "^2.8",
"laminas/laminas-servicemanager": "^3.5",
"laminas/laminas-stdlib": "^3.0",
"laminas/laminas-uri": "^2.5",
"laminas/laminas-validator": "^2.10.2"
"laminas/laminas-validator": "^2.13"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.0",
"phpstan/phpstan": "^0.10"
"phpstan/phpstan": "^0.12",
"phpspec/prophecy-phpunit": "^2.0"
},
"suggest": {
"laminas/laminas-servicemanager": "To support third-party validators and filters"
Expand Down
3 changes: 3 additions & 0 deletions test/FormElement/BaseFormElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use DOMDocument;
use DOMElement;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use ReflectionMethod;
use Xtreamwayz\HTMLFormValidator\FormElement\Text;
use function iterator_to_array;

class BaseFormElementTest extends TestCase
{
use ProphecyTrait;

public function dataAttributesProvider()
{
return [
Expand Down
3 changes: 3 additions & 0 deletions test/FormElementArraytest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace XtreamwayzTest\HTMLFormValidator;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ServerRequestInterface;
use Xtreamwayz\HTMLFormValidator\FormFactory;
use Xtreamwayz\HTMLFormValidator\ValidationResult;
Expand All @@ -15,6 +16,8 @@

class FormElementArraytest extends TestCase
{
use ProphecyTrait;

public function testCheckboxArrayIsValid() : void
{
$html = '
Expand Down
3 changes: 3 additions & 0 deletions test/FormFactoryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
use Xtreamwayz\HTMLFormValidator\FormFactoryFactory;
use Xtreamwayz\HTMLFormValidator\FormFactoryInterface;
use Laminas\InputFilter\Factory;
use Prophecy\PhpUnit\ProphecyTrait;

class FormFactoryFactoryTest extends TestCase
{
use ProphecyTrait;

/** @var ContainerInterface|ProphecyInterface */
private $container;

Expand Down
3 changes: 3 additions & 0 deletions test/FormFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
use Xtreamwayz\HTMLFormValidator\FormInterface;
use Laminas\InputFilter\Factory;
use Laminas\InputFilter\InputFilterInterface;
use Prophecy\PhpUnit\ProphecyTrait;

class FormFactoryTest extends TestCase
{
use ProphecyTrait;

public function testConstructorWithNoArguments() : void
{
$formFactory = new FormFactory();
Expand Down
11 changes: 7 additions & 4 deletions test/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
namespace XtreamwayzTest\HTMLFormValidator;

use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ServerRequestInterface;
use Xtreamwayz\HTMLFormValidator\FormFactory;
use Xtreamwayz\HTMLFormValidator\ValidationResult;

class FormTest extends TestCase
{
use ProphecyTrait;

private $rawValues = [
'foo' => 'bar',
'baz' => ' qux ',
Expand Down Expand Up @@ -104,8 +107,8 @@ public function testSetValuesStatically() : void
'baz' => 'qux',
]);

self::assertContains('<input type="text" name="foo" value="bar">', $form->asString());
self::assertContains('<input type="text" name="baz" value="qux">', $form->asString());
self::assertStringContainsString('<input type="text" name="foo" value="bar">', $form->asString());
self::assertStringContainsString('<input type="text" name="baz" value="qux">', $form->asString());
}

public function testSetValuesWithConstructor() : void
Expand All @@ -121,7 +124,7 @@ public function testSetValuesWithConstructor() : void
'baz' => 'qux',
]);

self::assertContains('<input type="text" name="foo" value="bar">', $form->asString());
self::assertContains('<input type="text" name="baz" value="qux">', $form->asString());
self::assertStringContainsString('<input type="text" name="foo" value="bar">', $form->asString());
self::assertStringContainsString('<input type="text" name="baz" value="qux">', $form->asString());
}
}

0 comments on commit 7e4692e

Please sign in to comment.