diff --git a/CHANGELOG.md b/CHANGELOG.md index 71814a4..70071a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Changed + +- Requires `innmind/black-box:~7.0` + ## 5.0.0 - 2026-01-25 ### Added diff --git a/blackbox.php b/blackbox.php index d6f7152..e750ba6 100644 --- a/blackbox.php +++ b/blackbox.php @@ -23,8 +23,7 @@ __DIR__.'/tests/', __DIR__.'/fixtures/', ) - ->dumpTo('coverage.clover') - ->enableWhen(true), + ->dumpTo('coverage.clover'), ) ->scenariiPerProof(50), ) diff --git a/composer.json b/composer.json index 7ab0468..9af9c2c 100644 --- a/composer.json +++ b/composer.json @@ -31,16 +31,16 @@ }, "require-dev": { "innmind/static-analysis": "~1.3", - "innmind/black-box": "~6.5", + "innmind/black-box": "~7.0", "innmind/coding-standard": "~2.0" }, "conflict": { - "innmind/black-box": "<6.0|~7.0" + "innmind/black-box": "<7.0|~8.0" }, "suggest": { "innmind/black-box": "For property based testing" }, "provide": { - "innmind/black-box-sets": "6.0" + "innmind/black-box-sets": "7.0" } } diff --git a/tests/AlphaTest.php b/tests/AlphaTest.php index 2806c6b..e00bd73 100644 --- a/tests/AlphaTest.php +++ b/tests/AlphaTest.php @@ -4,8 +4,10 @@ namespace Tests\Innmind\Colour; use Innmind\Colour\Alpha; -use Innmind\BlackBox\PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +use Innmind\BlackBox\PHPUnit\Framework\{ + TestCase, + Attributes\DataProvider, +}; class AlphaTest extends TestCase { @@ -46,18 +48,22 @@ public function testSub() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-0.1'); - - $_ = Alpha::of(-0.1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Alpha::of(-0.1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('1.1'); - - $_ = Alpha::of(1.1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Alpha::of(1.1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAtMaximum() diff --git a/tests/BlackTest.php b/tests/BlackTest.php index 132ad72..5f08cae 100644 --- a/tests/BlackTest.php +++ b/tests/BlackTest.php @@ -18,18 +18,22 @@ public function testInterface() public function testThrowWhenValueTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-1'); - - $_ = Black::of(-1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Black::of(-1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Black::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Black::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAdd() diff --git a/tests/BlueTest.php b/tests/BlueTest.php index 14836b3..606a05a 100644 --- a/tests/BlueTest.php +++ b/tests/BlueTest.php @@ -59,18 +59,22 @@ public function testSub() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-42'); - - $_ = Blue::of(-42)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Blue::of(-42)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('512'); - - $_ = Blue::of(512)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Blue::of(512)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAtMaximum() diff --git a/tests/CMYKATest.php b/tests/CMYKATest.php index f7fb1d1..b18877d 100644 --- a/tests/CMYKATest.php +++ b/tests/CMYKATest.php @@ -12,8 +12,10 @@ Alpha, RGBA, }; -use Innmind\BlackBox\PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +use Innmind\BlackBox\PHPUnit\Framework\{ + TestCase, + Attributes\DataProvider, +}; class CMYKATest extends TestCase { diff --git a/tests/ColourTest.php b/tests/ColourTest.php index cfd8f15..e62ee7f 100644 --- a/tests/ColourTest.php +++ b/tests/ColourTest.php @@ -22,10 +22,10 @@ }; use Innmind\BlackBox\{ PHPUnit\Framework\TestCase, + PHPUnit\Framework\Attributes\DataProvider, PHPUnit\BlackBox, Set, }; -use PHPUnit\Framework\Attributes\DataProvider; class ColourTest extends TestCase { @@ -61,10 +61,12 @@ public function testReturnNothingForRandomStrings() public function testThrowWhenNoFormatRecognized() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage("Cyan not found in 'foo'"); - - $_ = Colour::of('foo'); + $this + ->assert() + ->throws( + static fn() => Colour::of('foo'), + \DomainException::class, + ); } public function testLiterals() diff --git a/tests/CyanTest.php b/tests/CyanTest.php index b9bb10d..79bcf7c 100644 --- a/tests/CyanTest.php +++ b/tests/CyanTest.php @@ -18,18 +18,22 @@ public function testInterface() public function testThrowWhenValueTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-1'); - - $_ = Cyan::of(-1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Cyan::of(-1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Cyan::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Cyan::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAdd() diff --git a/tests/Fixtures/ColourTest.php b/tests/Fixtures/ColourTest.php index ff3d2ec..4397f91 100644 --- a/tests/Fixtures/ColourTest.php +++ b/tests/Fixtures/ColourTest.php @@ -15,13 +15,12 @@ class ColourTest extends TestCase { public function testInterface() { - $set = Colour::any(); + $set = Colour::any()->take(100); $this->assertInstanceOf(Set::class, $set); foreach ($set->values(Random::default) as $value) { $this->assertInstanceOf(Set\Value::class, $value); - $this->assertTrue($value->immutable()); $this->assertInstanceOf(RGBA::class, $value->unwrap()); } } diff --git a/tests/GreenTest.php b/tests/GreenTest.php index 025aaee..6576d0b 100644 --- a/tests/GreenTest.php +++ b/tests/GreenTest.php @@ -59,18 +59,22 @@ public function testSub() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-42'); - - $_ = Green::of(-42)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Green::of(-42)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('512'); - - $_ = Green::of(512)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Green::of(512)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAtMaximum() diff --git a/tests/HSLATest.php b/tests/HSLATest.php index e3eaf21..4c2bf23 100644 --- a/tests/HSLATest.php +++ b/tests/HSLATest.php @@ -12,8 +12,10 @@ RGBA, CMYKA, }; -use Innmind\BlackBox\PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +use Innmind\BlackBox\PHPUnit\Framework\{ + TestCase, + Attributes\DataProvider, +}; class HSLATest extends TestCase { diff --git a/tests/HueTest.php b/tests/HueTest.php index 8536b56..ca71017 100644 --- a/tests/HueTest.php +++ b/tests/HueTest.php @@ -4,8 +4,10 @@ namespace Tests\Innmind\Colour; use Innmind\Colour\Hue; -use Innmind\BlackBox\PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +use Innmind\BlackBox\PHPUnit\Framework\{ + TestCase, + Attributes\DataProvider, +}; class HueTest extends TestCase { @@ -19,18 +21,22 @@ public function testInterface() public function testThrowWhenValueTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-20'); - - $_ = Hue::of(-20)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Hue::of(-20)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('360'); - - $_ = Hue::of(360)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Hue::of(360)->unwrap(), + \OutOfBoundsException::class, + ); } #[DataProvider('rotations')] diff --git a/tests/IntensityTest.php b/tests/IntensityTest.php index 532de5b..cdee0fe 100644 --- a/tests/IntensityTest.php +++ b/tests/IntensityTest.php @@ -17,17 +17,21 @@ public function testInterface() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-1'); - - $_ = Intensity::of(-1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Intensity::of(-1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Intensity::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Intensity::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } } diff --git a/tests/LightnessTest.php b/tests/LightnessTest.php index 80014af..dfae2a3 100644 --- a/tests/LightnessTest.php +++ b/tests/LightnessTest.php @@ -44,18 +44,22 @@ public function testSub() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-42'); - - $_ = Lightness::of(-42)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Lightness::of(-42)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Lightness::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Lightness::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } public function testEquals() diff --git a/tests/MagentaTest.php b/tests/MagentaTest.php index c70346f..09f9f81 100644 --- a/tests/MagentaTest.php +++ b/tests/MagentaTest.php @@ -18,18 +18,22 @@ public function testInterface() public function testThrowWhenValueTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-1'); - - $_ = Magenta::of(-1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Magenta::of(-1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Magenta::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Magenta::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAdd() diff --git a/tests/RGBATest.php b/tests/RGBATest.php index 9f2cf7c..2a562f6 100644 --- a/tests/RGBATest.php +++ b/tests/RGBATest.php @@ -12,8 +12,10 @@ HSLA, CMYKA, }; -use Innmind\BlackBox\PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +use Innmind\BlackBox\PHPUnit\Framework\{ + TestCase, + Attributes\DataProvider, +}; class RGBATest extends TestCase { @@ -309,10 +311,12 @@ public function testFromRGBFunctionWithPoints() public function testThrowWhenInvalidRGBFunctionWithPoints() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage("Red not found in 'rgb(10, 20%, 30)'"); - - $_ = RGBA::of('rgb(10, 20%, 30)'); + $this + ->assert() + ->throws( + static fn() => RGBA::of('rgb(10, 20%, 30)'), + \DomainException::class, + ); } public function testFromRGBFunctionWithPercents() @@ -328,10 +332,12 @@ public function testFromRGBFunctionWithPercents() public function testThrowWhenInvalidRGBFunctionWithPercents() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage("Red not found in 'rgb(10, 20%, 30)'"); - - $_ = RGBA::of('rgb(10, 20%, 30)'); + $this + ->assert() + ->throws( + static fn() => RGBA::of('rgb(10, 20%, 30)'), + \DomainException::class, + ); } public function testFromRGBFunction() @@ -366,10 +372,12 @@ public function testFromRGBAFunctionWithPoints() public function testThrowWhenInvalidRGBAFunctionWithPoints() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage("Red not found in 'rgba(10, 20%, 30, 2.0)'"); - - RGBA::of('rgba(10, 20%, 30, 2.0)'); + $this + ->assert() + ->throws( + static fn() => RGBA::of('rgba(10, 20%, 30, 2.0)'), + \DomainException::class, + ); } public function testFromRGBAFunctionWithPercents() @@ -385,10 +393,12 @@ public function testFromRGBAFunctionWithPercents() public function testThrowWhenInvalidRGBAFunctionWithPercents() { - $this->expectException(\DomainException::class); - $this->expectExceptionMessage("Red not found in 'rgba(10, 20%, 30, 1)'"); - - RGBA::of('rgba(10, 20%, 30, 1)'); + $this + ->assert() + ->throws( + static fn() => RGBA::of('rgba(10, 20%, 30, 1)'), + \DomainException::class, + ); } public function testFromRGBAFunction() diff --git a/tests/RedTest.php b/tests/RedTest.php index e5532a3..f53a1c8 100644 --- a/tests/RedTest.php +++ b/tests/RedTest.php @@ -59,18 +59,22 @@ public function testSub() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-42'); - - $_ = Red::of(-42)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Red::of(-42)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('512'); - - $_ = Red::of(512)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Red::of(512)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAtMaximum() diff --git a/tests/SaturationTest.php b/tests/SaturationTest.php index a468525..3fba715 100644 --- a/tests/SaturationTest.php +++ b/tests/SaturationTest.php @@ -44,18 +44,22 @@ public function testSub() public function testThrowWhenValueIsTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-42'); - - $_ = Saturation::of(-42)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Saturation::of(-42)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueIsTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Saturation::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Saturation::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } public function testEquals() diff --git a/tests/YellowTest.php b/tests/YellowTest.php index 68ddaf9..20c70d1 100644 --- a/tests/YellowTest.php +++ b/tests/YellowTest.php @@ -18,18 +18,22 @@ public function testInterface() public function testThrowWhenValueTooLow() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('-1'); - - $_ = Yellow::of(-1)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Yellow::of(-1)->unwrap(), + \OutOfBoundsException::class, + ); } public function testThrowWhenValueTooHigh() { - $this->expectException(\OutOfBoundsException::class); - $this->expectExceptionMessage('101'); - - $_ = Yellow::of(101)->unwrap(); + $this + ->assert() + ->throws( + static fn() => Yellow::of(101)->unwrap(), + \OutOfBoundsException::class, + ); } public function testAdd()