diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9fb58b..e0ecfcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: include: - { php: 8.1, dependencies: "highest" } - { php: 8.2, dependencies: "highest" } + - { php: 8.3, dependencies: "highest" } steps: - name: Checkout uses: actions/checkout@v2 @@ -35,8 +36,11 @@ jobs: strategy: matrix: include: - - { phpunit: 10, php: 8.2 } - { phpunit: 10, php: 8.1 } + - { phpunit: 10, php: 8.2 } + - { phpunit: 10, php: 8.3 } + - { phpunit: 11, php: 8.2 } + - { phpunit: 11, php: 8.3 } steps: - name: Checkout uses: actions/checkout@v2 diff --git a/README.md b/README.md index eff6264..fa579b7 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ In property-based testing, several properties that the System Under Test must re ## Compatibility -- PHP 8.1, 8.2 -- PHPUnit 10.x +- PHP 8.1, 8.2, 8.3 +- PHPUnit 10.x, 11.x ## Installation diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0c9fd9f..d541203 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -435,11 +435,6 @@ parameters: count: 1 path: src/Generator/GeneratedValueSingle.php - - - message: "#^PHPDoc tag @param has invalid value \\(callable\\|Constraint\\)\\: Unexpected token \"\\\\n \", expected variable at offset 37$#" - count: 1 - path: src/Generator/SuchThatGenerator.php - - message: "#^Call to an undefined method Eris\\\\Generator\\\\GeneratedValue\\\\>\\:\\:first\\(\\)\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a89c6b0..9da82c8 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,307 +1,161 @@ - + + + + + + + - var_dump($name) + collected())]]> - var_dump($string) + - var_dump($set) + - public function __invoke($size, Random\RandomRange $rand); - public function shrink(GeneratedValue $element); + + - $associativeArray[$key] + - $halvedOffset + - $callable + - public static function fromJustValue($value, $generatorName = null) - public static function fromValueAndInput($value, $input, $generatorName = null) + + - new ArrayIterator([ + + ])]]> - \Traversable + - $value + - $value + - $value + - unbox + - $sequence + - unbox + - $set + - $maximumSubsetIndex + - $set + - - public function __construct($filter, $generator, $maximumAttempts = 100) - - $value + - $tuple + - $vector + + + + + + - - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - getName(false) - )]]> - - getName(false) - )]]> - getName + + + + + + + + + + + + + - first + - $subsetSizes + - last + - generatorName - generatorName - generatorName - unbox - unbox - unbox + + + + + + @@ -314,16 +168,11 @@ - null - null + + - shrinking + - - - $haystack - - diff --git a/src/Generator/SuchThatGenerator.php b/src/Generator/SuchThatGenerator.php index 22a799b..7b7dd18 100644 --- a/src/Generator/SuchThatGenerator.php +++ b/src/Generator/SuchThatGenerator.php @@ -36,9 +36,9 @@ class SuchThatGenerator implements Generator private $filter; private $generator; private $maximumAttempts; - + /** - * @param callable|Constraint + * @param callable|Constraint $filter */ public function __construct($filter, $generator, $maximumAttempts = 100) { diff --git a/src/TestTrait.php b/src/TestTrait.php index f1b003d..7bfe58a 100644 --- a/src/TestTrait.php +++ b/src/TestTrait.php @@ -3,7 +3,6 @@ use BadMethodCallException; use DateInterval; -use Doctrine\Common\Annotations\AnnotationReader; use Eris\Attributes\ErisDuration; use Eris\Attributes\ErisMethod; use Eris\Attributes\ErisRatio; @@ -16,6 +15,8 @@ use Eris\Random\RandomRange; use Eris\Random\RandSource; use Eris\Shrinker\ShrinkerFactory; +use PHPUnit\Framework\Attributes\Before; +use PHPUnit\Framework\Attributes\BeforeClass; use Throwable; trait TestTrait @@ -34,9 +35,7 @@ trait TestTrait protected $seed; protected $shrinkingTimeLimit; - /** - * @beforeClass - */ + #[BeforeClass] public static function erisSetupBeforeClass() { foreach (['Generator', 'Antecedent', 'Listener', 'Random'] as $namespace) { @@ -77,9 +76,7 @@ public function getTestCaseAttributes() ]; } - /** - * @before - */ + #[Before] public function erisSetup() { $this->seedingRandomNumberGeneration(); diff --git a/test/ExampleEnd2EndTest.php b/test/ExampleEnd2EndTest.php index 70fcfe2..f38d015 100644 --- a/test/ExampleEnd2EndTest.php +++ b/test/ExampleEnd2EndTest.php @@ -1,6 +1,7 @@ runExample($testCaseFileName); diff --git a/test/Generator/NamesGeneratorTest.php b/test/Generator/NamesGeneratorTest.php index be7955f..77ce0e4 100644 --- a/test/Generator/NamesGeneratorTest.php +++ b/test/Generator/NamesGeneratorTest.php @@ -3,6 +3,7 @@ use Eris\Random\RandomRange; use Eris\Random\RandSource; +use PHPUnit\Framework\Attributes\DataProvider; class NamesGeneratorTest extends \PHPUnit\Framework\TestCase { @@ -54,9 +55,7 @@ public static function namesToShrink(): array ]; } - /** - * @dataProvider namesToShrink - */ + #[DataProvider('namesToShrink')] public function testShrinksToTheNameWithTheImmediatelyLowerLengthWhichHasTheMinimumDistance($shrunk, $original): void { $generator = NamesGenerator::defaultDataSet(); diff --git a/test/Generator/RegexGeneratorTest.php b/test/Generator/RegexGeneratorTest.php index a53ff91..e02d46b 100644 --- a/test/Generator/RegexGeneratorTest.php +++ b/test/Generator/RegexGeneratorTest.php @@ -3,6 +3,7 @@ use Eris\Random\RandomRange; use Eris\Random\RandSource; +use PHPUnit\Framework\Attributes\DataProvider; class RegexGeneratorTest extends \PHPUnit\Framework\TestCase { @@ -33,9 +34,7 @@ protected function setUp(): void $this->rand = new RandomRange(new RandSource()); } - /** - * @dataProvider supportedRegexes - */ + #[DataProvider('supportedRegexes')] public function testGeneratesOnlyValuesThatMatchTheRegex($expression) { $generator = new RegexGenerator($expression); diff --git a/test/Generator/TupleGeneratorTest.php b/test/Generator/TupleGeneratorTest.php index 7dc47aa..fb08e7c 100644 --- a/test/Generator/TupleGeneratorTest.php +++ b/test/Generator/TupleGeneratorTest.php @@ -3,6 +3,7 @@ use Eris\Random\RandomRange; use Eris\Random\RandSource; +use PHPUnit\Framework\Attributes\Depends; class TupleGeneratorTest extends \PHPUnit\Framework\TestCase { @@ -129,9 +130,7 @@ public function testShrinkingMultipleOptionsOfOneGenerator(): void } } - /** - * @depends testShrinkingMultipleOptionsOfOneGenerator - */ + #[Depends('testShrinkingMultipleOptionsOfOneGenerator')] public function testShrinkingMultipleOptionsOfMoreThanOneSingleShrinkingGenerator(): void { $generator = new TupleGenerator([ @@ -161,9 +160,7 @@ public function testShrinkingMultipleOptionsOfMoreThanOneSingleShrinkingGenerato } } - /** - * @depends testShrinkingMultipleOptionsOfOneGenerator - */ + #[Depends('testShrinkingMultipleOptionsOfOneGenerator')] public function testShrinkingMultipleOptionsOfMoreThanOneMultipleShrinkingGenerator(): void { $generator = new TupleGenerator([ diff --git a/test/PHPUnitCommandTest.php b/test/PHPUnitCommandTest.php index 9400db9..6741a16 100644 --- a/test/PHPUnitCommandTest.php +++ b/test/PHPUnitCommandTest.php @@ -1,6 +1,8 @@ markTestSkipped('MersenneTwister class does not support HHVM'); } - $this->enableAssertions(); - } - - public function tearDown(): void - { - $this->disableAssertions(); } public static function sequences() @@ -25,10 +21,8 @@ public static function sequences() [0xfffffffffffffff, 100], ]; } - - /** - * @dataProvider sequences - */ + + #[DataProvider('sequences')] public function testGeneratesTheSameSequenceAsThePythonOracle($seed, $sample) { $twister = new MersenneTwister(); @@ -57,17 +51,4 @@ public function testDistribution() $this->assertGreaterThan(400, $count); } } - - private function enableAssertions() - { - assert_options(ASSERT_ACTIVE, 1); - assert_options(ASSERT_CALLBACK, function ($file, $line, $code) { - throw new \LogicException($code); - }); - } - - private function disableAssertions() - { - assert_options(ASSERT_ACTIVE, 0); - } } diff --git a/test/Shrinker/MultipleTest.php b/test/Shrinker/MultipleTest.php index 8d534f2..074ab9c 100644 --- a/test/Shrinker/MultipleTest.php +++ b/test/Shrinker/MultipleTest.php @@ -5,6 +5,7 @@ use Eris\Generator\IntegerGenerator; use Exception; use PHPUnit\Framework\AssertionFailedError; +use PHPUnit\Framework\Attributes\DataProvider; use RuntimeException; class MultipleTest extends \PHPUnit\Framework\TestCase @@ -43,10 +44,8 @@ public static function originallyFailedTests() ['startingPoint' => 100000], ]; } - - /** - * @dataProvider originallyFailedTests - */ + + #[DataProvider('originallyFailedTests')] public function testMultipleBranchesConvergeFasterThanLinearShrinking($startingPoint) { try {