Skip to content

Commit

Permalink
chore: (bc) Update PHP and PHPUnit minimum version requirements (#164)
Browse files Browse the repository at this point in the history
* chore: (bc) Update PHP and PHPUnit minimum version requirements

- Use attributes to handle what was previously handled through annotations

---------

Co-authored-by: Ilario Pierbattista <987038+ilario-pierbattista@users.noreply.github.com>
  • Loading branch information
Pixelshaped and ilario-pierbattista authored Apr 24, 2023
1 parent 3e43f40 commit b9474c7
Show file tree
Hide file tree
Showing 52 changed files with 267 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=php:7.4-cli-alpine3.14
ARG BASE_IMAGE=php:8.1-cli-alpine3.14
FROM ${BASE_IMAGE}

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4, 8.0]
php: [8.1]
dependencies:
- "lowest"
- "highest"
Expand All @@ -35,10 +35,8 @@ jobs:
strategy:
matrix:
include:
- { phpunit: 9, php: 8.2 }
- { phpunit: 9, php: 8.1 }
- { phpunit: 9, php: 8.0 }
- { phpunit: 8, php: 7.4 }
- { phpunit: 10, php: 8.2 }
- { phpunit: 10, php: 8.1 }
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
- name: Install dependencies
uses: "ramsey/composer-install@v1"
- run: ${{ matrix.script }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/vendor/
.php_cs.cache
.php-cs-fixer.cache
composer.lock
docs/_build
.phpunit.result.cache
docker-compose.override.yml
.psalm-cache/
.idea
.php-cs-fixer.cache
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The project follows [semantic versioning](http://semver.org/). `BC` stands for a change that impacts `Backward Compatibility`.

## [Unreleased]
### Added
* Support for PHP 8.2
### Removed
* Support for PHP < 8.1
* Support for PHPUnit < 10

## [0.14.0] - 2023-04-21
### Added
* `ilario-pierbattista/reverse-regex` as substitute peer dependency of `icomefromthenet/reverse-regex`.
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.PHONY: run-php-7.4
run-php-7.4:
docker-compose run php-7.4 sh

.PHONY: run-php-8.1
run-php-8.1:
docker-compose run php-8.1 sh
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ In property-based testing, several properties that the System Under Test must re

## Compatibility

- PHP 7.4, 8.0, 8.1, 8.2
- PHPUnit 8.x, 9.x
- PHP 8.1, 8.2
- PHPUnit 10.x

## Installation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
],
"license": "MIT",
"require": {
"php": ">=7.4"
"php": "^8.1"
},
"require-dev": {
"phpunit/phpunit": "^8 || ^9",
"phpunit/phpunit": "^10.0.4",
"sebastian/comparator": ">=2.1.3",
"friendsofphp/php-cs-fixer": "^3.0",
"ilario-pierbattista/reverse-regex": "^0.3.1",
Expand Down
9 changes: 0 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ version: "3.8"

# Add a docker-compose.override.yml if you need to change one of the following (it won't be tracked)
services:
php-7.4:
build:
context: .docker
args:
BASE_IMAGE: php:7.4-cli-alpine3.14
volumes:
- .:/usr/src/eris
user: 1000:1000
working_dir: /usr/src/eris
php-8.1:
build:
context: .docker
Expand Down
4 changes: 2 additions & 2 deletions examples/AssociativeArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function testAssociativeArraysGeneratedOnStandardKeys()
->then(function ($array) {
$this->assertCount(2, $array);
$letter = $array['letter'];
\Eris\PHPUnitDeprecationHelper::assertIsString($letter);
static::assertIsString($letter);
$cipher = $array['cipher'];
\Eris\PHPUnitDeprecationHelper::assertIsInt($cipher);
static::assertIsInt($cipher);
});
}
}
5 changes: 2 additions & 3 deletions examples/CharacterTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Eris\Antecedents;
use Eris\Attributes\ErisRatio;
use Eris\Generators;

class CharacterTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -43,9 +44,7 @@ public function testMultiplePrintableCharacters()
});
}

/**
* @eris-ratio 10
*/
#[ErisRatio(ratio: 10)]
public function testMultiplePrintableCharactersFromAnnotation()
{
$this
Expand Down
2 changes: 1 addition & 1 deletion examples/GeneratorSamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private function generateSample($description, $generator)
echo PHP_EOL;
echo $description . " with size 10";
$sample = $this->sample($generator);
\Eris\PHPUnitDeprecationHelper::assertIsArray($sample->collected());
static::assertIsArray($sample->collected());
$this->prettyPrint($sample->collected());
}

Expand Down
15 changes: 7 additions & 8 deletions examples/LimitToTest.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?php

use Eris\Attributes\ErisDuration;
use Eris\Attributes\ErisRatio;
use Eris\Attributes\ErisRepeat;
use Eris\Generators;
use Eris\TestTrait;

class LimitToTest extends \PHPUnit\Framework\TestCase
{
use TestTrait;

/**
* @eris-repeat 5
*/
#[ErisRepeat(repeat: 5)]
public function testNumberOfIterationsCanBeConfigured()
{
$this->forAll(
Generators::int()
)
->then(function ($value) {
\Eris\PHPUnitDeprecationHelper::assertIsInt($value);
static::assertIsInt($value);
});
}

Expand Down Expand Up @@ -50,10 +51,8 @@ public function testTimeIntervalToRunForCanBeConfiguredAndAVeryLowNumberOfIterat
});
}

/**
* @eris-ratio 0
* @eris-duration PT2S
*/
#[ErisRatio(ratio: 0)]
#[ErisDuration(duration: 'PT2S')]
public function testTimeIntervalToRunForCanBeConfiguredAndAVeryLowNumberOfIterationsCanBeIgnoredFromAnnotation()
{
$this->forAll(
Expand Down
2 changes: 1 addition & 1 deletion examples/LogFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testWritingIterationsOnALogFile(): void
)
->hook(Listeners::log(sys_get_temp_dir().'/eris-log-file-test.log'))
->then(function ($number) {
\Eris\PHPUnitDeprecationHelper::assertIsInt($number);
static::assertIsInt($number);
});
}

Expand Down
5 changes: 2 additions & 3 deletions examples/MinimumEvaluationsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Eris\Attributes\ErisRatio;
use Eris\Generators;

class MinimumEvaluationsTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -35,9 +36,7 @@ public function testPassesBecauseOfTheArtificiallyLowMinimumEvaluationRatio()
});
}

/**
* @eris-ratio 1
*/
#[ErisRatio(ratio: 1)]
public function testPassesBecauseOfTheArtificiallyLowMinimumEvaluationRatioFromAnnotation()
{
$this
Expand Down
4 changes: 2 additions & 2 deletions examples/NamesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testGeneratingNames()
$this->forAll(
Generators::names()
)->then(function ($name) {
\Eris\PHPUnitDeprecationHelper::assertIsString($name);
static::assertIsString($name);
var_dump($name);
});
}
Expand All @@ -21,7 +21,7 @@ public function testSamplingShrinkingOfNames()
{
$generator = Generator\NamesGenerator::defaultDataSet();
$sample = $this->sampleShrink($generator);
\Eris\PHPUnitDeprecationHelper::assertIsArray($sample->collected());
static::assertIsArray($sample->collected());
var_dump($sample->collected());
}
}
12 changes: 4 additions & 8 deletions examples/RandConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Eris\Attributes\ErisMethod;
use Eris\Generators;
use Eris\Random;
use Eris\TestTrait;
Expand All @@ -19,9 +20,7 @@ public function testUsingTheDefaultRandFunction()
->then($this->isInteger());
}

/**
* @eris-method rand
*/
#[ErisMethod(method: 'rand')]
public function testUsingTheDefaultRandFunctionFromAnnotation()
{
$this
Expand All @@ -42,10 +41,7 @@ public function testUsingTheDefaultMtRandFunction()
->then($this->isInteger());
}


/**
* @eris-method mt_rand
*/
#[ErisMethod(method: 'mt_rand')]
public function testUsingTheDefaultMtRandFunctionFromAnnotation()
{
$this
Expand All @@ -72,7 +68,7 @@ public function testUsingThePurePhpMtRandFunction()
private function isInteger()
{
return function ($number) {
\Eris\PHPUnitDeprecationHelper::assertIsInt($number);
static::assertIsInt($number);
};
}
}
2 changes: 1 addition & 1 deletion examples/SetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testSetsOfAnotherGeneratorsDomain()
Generators::set(Generators::nat())
)
->then(function ($set) {
\Eris\PHPUnitDeprecationHelper::assertIsArray($set);
static::assertIsArray($set);
foreach ($set as $element) {
$this->assertGreaterThanOrEqual(0, $element);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ShrinkingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testShrinkingAString()
)
->then(function ($string) {
var_dump($string);
\Eris\PHPUnitDeprecationHelper::assertStringNotContainsString('B', $string);
static::assertStringNotContainsString('B', $string);
});
}

Expand Down
5 changes: 2 additions & 3 deletions examples/ShrinkingTimeLimitTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Eris\Attributes\ErisShrink;
use Eris\Generator;
use Eris\Generators;

Expand Down Expand Up @@ -34,9 +35,7 @@ public function testLengthPreservation()
});
}

/**
* @eris-shrink 2
*/
#[ErisShrink(shrink: 2)]
public function testLengthPreservationFromAnnotation()
{
$this
Expand Down
2 changes: 1 addition & 1 deletion examples/SubsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testSubsetsOfASet()
])
)
->then(function ($set) {
\Eris\PHPUnitDeprecationHelper::assertIsArray($set);
static::assertIsArray($set);
foreach ($set as $element) {
$this->assertTrue($this->isEven($element), "Element $element is not even, where did it come from?");
}
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
</testsuite>
<testsuite name="EndToEnd">
<file>./test/ExampleEnd2EndTest.php</file>
<file>./test/PHPUnitDeprecationHelper.php</file>
</testsuite>
</testsuites>
<php>
Expand Down
11 changes: 11 additions & 0 deletions src/Attributes/ErisAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Eris\Attributes;

interface ErisAttribute
{
/**
* @return int|string
*/
public function getValue();
}
20 changes: 20 additions & 0 deletions src/Attributes/ErisDuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Eris\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD)]
class ErisDuration implements ErisAttribute
{
public function __construct(
public string $duration
) {
}


public function getValue()
{
return $this->duration;
}
}
19 changes: 19 additions & 0 deletions src/Attributes/ErisMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Eris\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD)]
class ErisMethod implements ErisAttribute
{
public function __construct(
public string $method
) {
}

public function getValue()
{
return $this->method;
}
}
19 changes: 19 additions & 0 deletions src/Attributes/ErisRatio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Eris\Attributes;

use Attribute;

#[Attribute(Attribute::TARGET_CLASS|Attribute::TARGET_METHOD)]
class ErisRatio implements ErisAttribute
{
public function __construct(
public int $ratio
) {
}

public function getValue()
{
return $this->ratio;
}
}
Loading

0 comments on commit b9474c7

Please sign in to comment.