From d1a76be08e054563240917c1a3ecfd9990bf93e1 Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 17 Apr 2026 17:59:33 +0000 Subject: [PATCH 1/4] Bump PHPUnit dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b57b51e..9cf30da 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ }, "require-dev": { "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0", - "phpunit/phpunit": "^9.0|^10.0|^11.0" + "phpunit/phpunit": "^12.0" }, "autoload": { "psr-4": { From ade875b718ae684975a1208241f3fdfbb0fe1c9d Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 17 Apr 2026 17:59:33 +0000 Subject: [PATCH 2/4] Adopt PHP attributes in test classes --- tests/Feature/MacrosTest.php | 5 +++-- tests/Feature/RangesCastingTest.php | 19 ++++++++++--------- tests/Feature/SqlGenerationTest.php | 13 +++++++------ tests/Feature/TimeRangeConfigTest.php | 3 ++- tests/Unit/RangesCanonizationTest.php | 5 +++-- tests/Unit/RangesJsonSerializationTest.php | 11 ++++++----- tests/Unit/RangesSerializationTest.php | 11 ++++++----- .../RangesWithDatesInitializationTest.php | 10 ++++------ 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/tests/Feature/MacrosTest.php b/tests/Feature/MacrosTest.php index 10fbbaf..b68c7dc 100644 --- a/tests/Feature/MacrosTest.php +++ b/tests/Feature/MacrosTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Feature; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Macros\QueryBuilderMacros; use Belamov\PostgresRange\Models\Range; use Belamov\PostgresRange\Ranges\DateRange; @@ -22,7 +23,7 @@ class MacrosTest extends TestCase private IntegerRange $range; private string $columnName = 'integer_range'; - /** @test */ + #[Test] public function macros_test(): void { $macros = new QueryBuilderMacros(); @@ -40,7 +41,7 @@ public function macros_test(): void } } - /** @test */ + #[Test] public function query_builder_macros_do_not_throw_any_exceptions(): void { $macros = new QueryBuilderMacros(); diff --git a/tests/Feature/RangesCastingTest.php b/tests/Feature/RangesCastingTest.php index 7d90248..45fbddf 100644 --- a/tests/Feature/RangesCastingTest.php +++ b/tests/Feature/RangesCastingTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Feature; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Ranges\DateRange; use Belamov\PostgresRange\Ranges\FloatRange; use Belamov\PostgresRange\Ranges\IntegerRange; @@ -17,7 +18,7 @@ class RangesCastingTest extends TestCase { use RefreshDatabase; - /** @test */ + #[Test] public function it_casts_timestamp_range_column(): void { $from = '2010-01-01 14:30:30'; @@ -37,7 +38,7 @@ public function it_casts_timestamp_range_column(): void $this->assertEquals($to, $model->timestamp_range->to()->toDateTimeString()); } - /** @test */ + #[Test] public function it_does_not_detect_changes_when_updating_with_same_timestamp_range(): void { $from = '2010-01-01 14:30:30'; @@ -60,7 +61,7 @@ public function it_does_not_detect_changes_when_updating_with_same_timestamp_ran $this->assertEquals((string) $model->getOriginal('timestamp_range'), (string) $model->timestamp_range); } - /** @test */ + #[Test] public function it_casts_timestamptz_range_column(): void { $from = '2010-01-01 14:30:30-2:00'; @@ -80,7 +81,7 @@ public function it_casts_timestamptz_range_column(): void $this->assertEquals(CarbonImmutable::parse($to)->timezone('UTC')->toDateTimeString(), $model->timestamptz_range->to()->toDateTimeString()); } - /** @test */ + #[Test] public function it_casts_time_range_column(): void { $from = '14:30:30'; @@ -100,7 +101,7 @@ public function it_casts_time_range_column(): void $this->assertEquals($to, $model->time_range->to()); } - /** @test */ + #[Test] public function it_casts_date_range_column(): void { $from = CarbonImmutable::parse('2010-01-10'); @@ -122,7 +123,7 @@ public function it_casts_date_range_column(): void $this->assertEquals($to, $model->date_range->to()); } - /** @test */ + #[Test] public function it_casts_float_range_column(): void { $from = 1.5; @@ -144,7 +145,7 @@ public function it_casts_float_range_column(): void $this->assertEquals($to, $model->float_range->to()); } - /** @test */ + #[Test] public function it_casts_integer_and_bigint_range_column(): void { $from = 10; @@ -174,7 +175,7 @@ public function it_casts_integer_and_bigint_range_column(): void $this->assertEquals($to, $model->bigint_range->to()); } - /** @test */ + #[Test] public function it_casts_empty_values_to_null(): void { $model = $this->createModel( @@ -198,7 +199,7 @@ public function it_casts_empty_values_to_null(): void $this->assertNull($model->date_range); } - /** @test */ + #[Test] public function it_casts_empty_boundaries_to_null(): void { $rangeFields = [ diff --git a/tests/Feature/SqlGenerationTest.php b/tests/Feature/SqlGenerationTest.php index 53d1410..5cc6232 100644 --- a/tests/Feature/SqlGenerationTest.php +++ b/tests/Feature/SqlGenerationTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Ranges\FloatRange; use Belamov\PostgresRange\Ranges\IntegerRange; use Belamov\PostgresRange\Tests\TestCase; @@ -15,7 +16,7 @@ class SqlGenerationTest extends TestCase { use RefreshDatabase; - /** @test */ + #[Test] public function it_creates_nullable_columns(): void { $model = $this->createModel([]); @@ -31,7 +32,7 @@ public function it_creates_nullable_columns(): void $this->assertNull($model->date_range_nullable); } - /** @test */ + #[Test] public function it_creates_columns_with_default_values(): void { $model = $this->createModel([]); @@ -53,7 +54,7 @@ public function it_creates_columns_with_default_values(): void $this->assertEquals('[2010-01-01,2010-01-02)', $model->getRawOriginal('date_range_with_default')); } - /** @test */ + #[Test] public function it_creates_indexes(): void { $indexes = DB::select( @@ -79,7 +80,7 @@ public function it_creates_indexes(): void ); } - /** @test */ + #[Test] public function it_generates_unique_constraints(): void { $this->expectException(QueryException::class); @@ -91,7 +92,7 @@ public function it_generates_unique_constraints(): void $this->createModel(['bigint_range_nullable' => $integerRange]); } - /** @test */ + #[Test] public function it_generates_unique_constraints_with_additional_column(): void { $this->expectException(QueryException::class); @@ -103,7 +104,7 @@ public function it_generates_unique_constraints_with_additional_column(): void $this->createModel(['integer_range_nullable' => $integerRange, 'column1' => 1]); } - /** @test */ + #[Test] public function it_generates_unique_constraints_with_additional_columns(): void { $this->expectException(QueryException::class); diff --git a/tests/Feature/TimeRangeConfigTest.php b/tests/Feature/TimeRangeConfigTest.php index 0c06d5b..d52b33a 100644 --- a/tests/Feature/TimeRangeConfigTest.php +++ b/tests/Feature/TimeRangeConfigTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Tests\TestCase; use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -12,7 +13,7 @@ class TimeRangeConfigTest extends TestCase { use RefreshDatabase; - /** @test */ + #[Test] public function it_takes_timerange_type_name_from_config(): void { $timeRangeTypeName = 'testing_timerange_type_name'; diff --git a/tests/Unit/RangesCanonizationTest.php b/tests/Unit/RangesCanonizationTest.php index b069f44..57544d8 100644 --- a/tests/Unit/RangesCanonizationTest.php +++ b/tests/Unit/RangesCanonizationTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Ranges\DateRange; use Belamov\PostgresRange\Ranges\IntegerRange; use Belamov\PostgresRange\Tests\TestCase; @@ -9,7 +10,7 @@ class RangesCanonizationTest extends TestCase { - /** @test */ + #[Test] public function it_canonicalizes_integer_range(): void { $range = new IntegerRange(10, 20, '(', ')'); @@ -55,7 +56,7 @@ public function it_canonicalizes_integer_range(): void $this->assertEquals('[10,)', (string) $range); } - /** @test */ + #[Test] public function it_canonicalizes_date_range(): void { $from = CarbonImmutable::parse('2010-01-10'); diff --git a/tests/Unit/RangesJsonSerializationTest.php b/tests/Unit/RangesJsonSerializationTest.php index 9fe68cc..a4951dc 100644 --- a/tests/Unit/RangesJsonSerializationTest.php +++ b/tests/Unit/RangesJsonSerializationTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Ranges\DateRange; use Belamov\PostgresRange\Ranges\FloatRange; use Belamov\PostgresRange\Ranges\IntegerRange; @@ -12,7 +13,7 @@ class RangesJsonSerializationTest extends TestCase { - /** @test */ + #[Test] public function timestamp_range_json_serializes_correctly(): void { $range = new TimestampRange('2010-01-01 14:30:30', '2010-01-01 15:30:30', '[', ']'); @@ -34,7 +35,7 @@ public function timestamp_range_json_serializes_correctly(): void $this->assertEquals('"[,]"', json_encode($range)); } - /** @test */ + #[Test] public function time_range_json_serializes_correctly(): void { $range = new TimeRange('14:30', '15:30', '[', ']'); @@ -56,7 +57,7 @@ public function time_range_json_serializes_correctly(): void $this->assertEquals('"[,]"', json_encode($range)); } - /** @test */ + #[Test] public function numeric_range_json_serializes_correctly(): void { $range = new FloatRange(1.5, 2.5, '[', ']'); @@ -78,7 +79,7 @@ public function numeric_range_json_serializes_correctly(): void $this->assertEquals('"[,]"', json_encode($range)); } - /** @test */ + #[Test] public function integer_range_json_serializes_correctly(): void { $range = new IntegerRange(10, 20, '[', ']'); @@ -103,7 +104,7 @@ public function integer_range_json_serializes_correctly(): void $this->assertEquals('"[,)"', json_encode($range)); } - /** @test */ + #[Test] public function date_range_json_serializes_correctly(): void { $from = CarbonImmutable::parse('2010-01-10'); diff --git a/tests/Unit/RangesSerializationTest.php b/tests/Unit/RangesSerializationTest.php index 5a918cd..9a8c5f3 100644 --- a/tests/Unit/RangesSerializationTest.php +++ b/tests/Unit/RangesSerializationTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Ranges\DateRange; use Belamov\PostgresRange\Ranges\FloatRange; use Belamov\PostgresRange\Ranges\IntegerRange; @@ -12,7 +13,7 @@ class RangesSerializationTest extends TestCase { - /** @test */ + #[Test] public function timestamp_range_serializes_correctly(): void { $range = new TimestampRange('2010-01-01 14:30:30', '2010-01-01 15:30:30', '[', ']'); @@ -34,7 +35,7 @@ public function timestamp_range_serializes_correctly(): void $this->assertEquals('[,]', (string) $range); } - /** @test */ + #[Test] public function time_range_serializes_correctly(): void { $range = new TimeRange('14:30', '15:30', '[', ']'); @@ -56,7 +57,7 @@ public function time_range_serializes_correctly(): void $this->assertEquals('[,]', (string) $range); } - /** @test */ + #[Test] public function numeric_range_serializes_correctly(): void { $range = new FloatRange(1.5, 2.5, '[', ']'); @@ -78,7 +79,7 @@ public function numeric_range_serializes_correctly(): void $this->assertEquals('[,]', (string) $range); } - /** @test */ + #[Test] public function integer_range_serializes_correctly(): void { $range = new IntegerRange(10, 20, '[', ']'); @@ -103,7 +104,7 @@ public function integer_range_serializes_correctly(): void $this->assertEquals('[,)', (string) $range); } - /** @test */ + #[Test] public function date_range_serializes_correctly(): void { $from = CarbonImmutable::parse('2010-01-10'); diff --git a/tests/Unit/RangesWithDatesInitializationTest.php b/tests/Unit/RangesWithDatesInitializationTest.php index 017f1ae..1210d91 100644 --- a/tests/Unit/RangesWithDatesInitializationTest.php +++ b/tests/Unit/RangesWithDatesInitializationTest.php @@ -2,6 +2,7 @@ namespace Belamov\PostgresRange\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use Belamov\PostgresRange\Ranges\DateRange; use Belamov\PostgresRange\Ranges\TimeRange; use Belamov\PostgresRange\Ranges\TimestampRange; @@ -13,10 +14,9 @@ class RangesWithDatesInitializationTest extends TestCase { /** - * @test - * * @throws Exception */ + #[Test] public function date_range_can_be_initialized_with_strings_or_date_object(): void { $fromString = '2010-01-10'; @@ -43,10 +43,9 @@ public function date_range_can_be_initialized_with_strings_or_date_object(): voi } /** - * @test - * * @throws Exception */ + #[Test] public function timestamp_range_can_be_initialized_with_strings_or_date_object(): void { $fromString = '2010-01-10 14:30:30'; @@ -73,10 +72,9 @@ public function timestamp_range_can_be_initialized_with_strings_or_date_object() } /** - * @test - * * @throws Exception */ + #[Test] public function time_range_can_be_initialized_with_strings_or_date_object(): void { $fromString = '14:30:30'; From f52c321b73eb7c1b1f0975204fdda2e062a2b16e Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 17 Apr 2026 17:59:33 +0000 Subject: [PATCH 3/4] Define test classes as `final` --- tests/Feature/MacrosTest.php | 2 +- tests/Feature/RangesCastingTest.php | 2 +- tests/Feature/SqlGenerationTest.php | 2 +- tests/Feature/TimeRangeConfigTest.php | 2 +- tests/Unit/RangesCanonizationTest.php | 2 +- tests/Unit/RangesJsonSerializationTest.php | 2 +- tests/Unit/RangesSerializationTest.php | 2 +- tests/Unit/RangesWithDatesInitializationTest.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Feature/MacrosTest.php b/tests/Feature/MacrosTest.php index b68c7dc..458630e 100644 --- a/tests/Feature/MacrosTest.php +++ b/tests/Feature/MacrosTest.php @@ -16,7 +16,7 @@ use CreateRangesTestTable; use Illuminate\Foundation\Testing\RefreshDatabase; -class MacrosTest extends TestCase +final class MacrosTest extends TestCase { use RefreshDatabase; diff --git a/tests/Feature/RangesCastingTest.php b/tests/Feature/RangesCastingTest.php index 45fbddf..77df7d1 100644 --- a/tests/Feature/RangesCastingTest.php +++ b/tests/Feature/RangesCastingTest.php @@ -14,7 +14,7 @@ use CreateRangesTestTable; use Illuminate\Foundation\Testing\RefreshDatabase; -class RangesCastingTest extends TestCase +final class RangesCastingTest extends TestCase { use RefreshDatabase; diff --git a/tests/Feature/SqlGenerationTest.php b/tests/Feature/SqlGenerationTest.php index 5cc6232..3fe6231 100644 --- a/tests/Feature/SqlGenerationTest.php +++ b/tests/Feature/SqlGenerationTest.php @@ -12,7 +12,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\DB; -class SqlGenerationTest extends TestCase +final class SqlGenerationTest extends TestCase { use RefreshDatabase; diff --git a/tests/Feature/TimeRangeConfigTest.php b/tests/Feature/TimeRangeConfigTest.php index d52b33a..ae1e3da 100644 --- a/tests/Feature/TimeRangeConfigTest.php +++ b/tests/Feature/TimeRangeConfigTest.php @@ -9,7 +9,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; -class TimeRangeConfigTest extends TestCase +final class TimeRangeConfigTest extends TestCase { use RefreshDatabase; diff --git a/tests/Unit/RangesCanonizationTest.php b/tests/Unit/RangesCanonizationTest.php index 57544d8..9cc4c15 100644 --- a/tests/Unit/RangesCanonizationTest.php +++ b/tests/Unit/RangesCanonizationTest.php @@ -8,7 +8,7 @@ use Belamov\PostgresRange\Tests\TestCase; use Carbon\CarbonImmutable; -class RangesCanonizationTest extends TestCase +final class RangesCanonizationTest extends TestCase { #[Test] public function it_canonicalizes_integer_range(): void diff --git a/tests/Unit/RangesJsonSerializationTest.php b/tests/Unit/RangesJsonSerializationTest.php index a4951dc..9bc01cc 100644 --- a/tests/Unit/RangesJsonSerializationTest.php +++ b/tests/Unit/RangesJsonSerializationTest.php @@ -11,7 +11,7 @@ use Belamov\PostgresRange\Tests\TestCase; use Carbon\CarbonImmutable; -class RangesJsonSerializationTest extends TestCase +final class RangesJsonSerializationTest extends TestCase { #[Test] public function timestamp_range_json_serializes_correctly(): void diff --git a/tests/Unit/RangesSerializationTest.php b/tests/Unit/RangesSerializationTest.php index 9a8c5f3..9335859 100644 --- a/tests/Unit/RangesSerializationTest.php +++ b/tests/Unit/RangesSerializationTest.php @@ -11,7 +11,7 @@ use Belamov\PostgresRange\Tests\TestCase; use Carbon\CarbonImmutable; -class RangesSerializationTest extends TestCase +final class RangesSerializationTest extends TestCase { #[Test] public function timestamp_range_serializes_correctly(): void diff --git a/tests/Unit/RangesWithDatesInitializationTest.php b/tests/Unit/RangesWithDatesInitializationTest.php index 1210d91..f5cde77 100644 --- a/tests/Unit/RangesWithDatesInitializationTest.php +++ b/tests/Unit/RangesWithDatesInitializationTest.php @@ -11,7 +11,7 @@ use DateTime; use Exception; -class RangesWithDatesInitializationTest extends TestCase +final class RangesWithDatesInitializationTest extends TestCase { /** * @throws Exception From 76d7292c636ed48932e67e6fa7054a466a8578f4 Mon Sep 17 00:00:00 2001 From: belamov <13860486+belamov@users.noreply.github.com> Date: Sat, 18 Apr 2026 00:45:04 +0500 Subject: [PATCH 4/4] Apply suggestion from @belamov --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9cf30da..b57b51e 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ }, "require-dev": { "orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0", - "phpunit/phpunit": "^12.0" + "phpunit/phpunit": "^9.0|^10.0|^11.0" }, "autoload": { "psr-4": {