Skip to content

Commit

Permalink
Solve own deprecations. Update test matrix for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixelshaped committed Mar 1, 2024
1 parent 56a2b12 commit 414af83
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 53 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,8 +36,12 @@ 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.1 }
- { phpunit: 11, php: 8.2 }
- { phpunit: 11, php: 8.3 }
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
5 changes: 1 addition & 4 deletions src/Generator/SuchThatGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ class SuchThatGenerator implements Generator
private $filter;
private $generator;
private $maximumAttempts;

/**
* @param callable|Constraint
*/

public function __construct($filter, $generator, $maximumAttempts = 100)
{
$this->filter = $filter;
Expand Down
5 changes: 2 additions & 3 deletions test/ExampleEnd2EndTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Eris;

use PHPUnit\Framework\Attributes\DataProvider;
use SimpleXMLElement;

class ExampleEnd2EndTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -37,9 +38,7 @@ public static function fullyGreenTestFiles()
];
}

/**
* @dataProvider fullyGreenTestFiles
*/
#[DataProvider('fullyGreenTestFiles')]
public function testAllTestClassesWhichAreFullyGreen($testCaseFileName)
{
$this->runExample($testCaseFileName);
Expand Down
5 changes: 2 additions & 3 deletions test/Generator/NamesGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Eris\Random\RandomRange;
use Eris\Random\RandSource;
use PHPUnit\Framework\Attributes\DataProvider;

class NamesGeneratorTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -54,9 +55,7 @@ public static function namesToShrink(): array
];
}

/**
* @dataProvider namesToShrink
*/
#[DataProvider('namesToShrink')]
public function testShrinksToTheNameWithTheImmediatelyLowerLengthWhichHasTheMinimumDistance($shrunk, $original): void
{
$generator = NamesGenerator::defaultDataSet();
Expand Down
5 changes: 2 additions & 3 deletions test/Generator/RegexGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Eris\Random\RandomRange;
use Eris\Random\RandSource;
use PHPUnit\Framework\Attributes\DataProvider;

class RegexGeneratorTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions test/Generator/TupleGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Eris\Random\RandomRange;
use Eris\Random\RandSource;
use PHPUnit\Framework\Attributes\Depends;

class TupleGeneratorTest extends \PHPUnit\Framework\TestCase
{
Expand Down Expand Up @@ -129,9 +130,7 @@ public function testShrinkingMultipleOptionsOfOneGenerator(): void
}
}

/**
* @depends testShrinkingMultipleOptionsOfOneGenerator
*/
#[Depends('testShrinkingMultipleOptionsOfOneGenerator')]
public function testShrinkingMultipleOptionsOfMoreThanOneSingleShrinkingGenerator(): void
{
$generator = new TupleGenerator([
Expand Down Expand Up @@ -161,9 +160,7 @@ public function testShrinkingMultipleOptionsOfMoreThanOneSingleShrinkingGenerato
}
}

/**
* @depends testShrinkingMultipleOptionsOfOneGenerator
*/
#[Depends('testShrinkingMultipleOptionsOfOneGenerator')]
public function testShrinkingMultipleOptionsOfMoreThanOneMultipleShrinkingGenerator(): void
{
$generator = new TupleGenerator([
Expand Down
6 changes: 3 additions & 3 deletions test/PHPUnitCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Eris;

use PHPUnit\Framework\Attributes\DataProvider;

class PHPUnitCommandTest extends \PHPUnit\Framework\TestCase
{
public static function commandExamples()
Expand All @@ -17,9 +19,7 @@ public static function commandExamples()
];
}

/**
* @dataProvider commandExamples
*/
#[DataProvider('commandExamples')]
public function testItCanComposeFrom($name, $fullString)
{
$command = PHPUnitCommand::fromSeedAndName(42, $name);
Expand Down
6 changes: 3 additions & 3 deletions test/Quantifier/SizeTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Eris\Quantifier;

use PHPUnit\Framework\Attributes\DataProvider;

class SizeTest extends \PHPUnit\Framework\TestCase
{
public function testProducesAListOfSizesIncreasingThemTriangularly()
Expand Down Expand Up @@ -41,9 +43,7 @@ public static function limits()
];
}

/**
* @dataProvider limits
*/
#[DataProvider('limits')]
public function testCoversAUniformSubsetWhenLimitedToTheNumberOfIterations($limit)
{
$size = Size::withTriangleGrowth(1000)
Expand Down
27 changes: 4 additions & 23 deletions test/Random/MersenneTwisterTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?php
namespace Eris\Random;

use PHPUnit\Framework\Attributes\DataProvider;

class MersenneTwisterTest extends \PHPUnit\Framework\TestCase
{
public function setUp(): void
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('MersenneTwister class does not support HHVM');
}
$this->enableAssertions();
}

public function tearDown(): void
{
$this->disableAssertions();
}

public static function sequences()
Expand All @@ -25,10 +21,8 @@ public static function sequences()
[0xfffffffffffffff, 100],
];
}

/**
* @dataProvider sequences
*/

#[DataProvider('sequences')]
public function testGeneratesTheSameSequenceAsThePythonOracle($seed, $sample)
{
$twister = new MersenneTwister();
Expand Down Expand Up @@ -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);
}
}
7 changes: 3 additions & 4 deletions test/Shrinker/MultipleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,10 +44,8 @@ public static function originallyFailedTests()
['startingPoint' => 100000],
];
}

/**
* @dataProvider originallyFailedTests
*/

#[DataProvider('originallyFailedTests')]
public function testMultipleBranchesConvergeFasterThanLinearShrinking($startingPoint)
{
try {
Expand Down

0 comments on commit 414af83

Please sign in to comment.