diff --git a/tests/Feature/MacrosTest.php b/tests/Feature/MacrosTest.php index 10fbbaf..458630e 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; @@ -15,14 +16,14 @@ use CreateRangesTestTable; use Illuminate\Foundation\Testing\RefreshDatabase; -class MacrosTest extends TestCase +final class MacrosTest extends TestCase { use RefreshDatabase; 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..77df7d1 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; @@ -13,11 +14,11 @@ use CreateRangesTestTable; use Illuminate\Foundation\Testing\RefreshDatabase; -class RangesCastingTest extends TestCase +final 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..3fe6231 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; @@ -11,11 +12,11 @@ use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\DB; -class SqlGenerationTest extends TestCase +final 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..ae1e3da 100644 --- a/tests/Feature/TimeRangeConfigTest.php +++ b/tests/Feature/TimeRangeConfigTest.php @@ -2,17 +2,18 @@ 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; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; -class TimeRangeConfigTest extends TestCase +final 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..9cc4c15 100644 --- a/tests/Unit/RangesCanonizationTest.php +++ b/tests/Unit/RangesCanonizationTest.php @@ -2,14 +2,15 @@ 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; use Carbon\CarbonImmutable; -class RangesCanonizationTest extends TestCase +final 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..9bc01cc 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; @@ -10,9 +11,9 @@ use Belamov\PostgresRange\Tests\TestCase; use Carbon\CarbonImmutable; -class RangesJsonSerializationTest extends TestCase +final 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..9335859 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; @@ -10,9 +11,9 @@ use Belamov\PostgresRange\Tests\TestCase; use Carbon\CarbonImmutable; -class RangesSerializationTest extends TestCase +final 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..f5cde77 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; @@ -10,13 +11,12 @@ use DateTime; use Exception; -class RangesWithDatesInitializationTest extends TestCase +final 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';