Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tests/Feature/MacrosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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();
Expand Down
21 changes: 11 additions & 10 deletions tests/Feature/RangesCastingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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');
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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 = [
Expand Down
15 changes: 8 additions & 7 deletions tests/Feature/SqlGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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([]);
Expand All @@ -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([]);
Expand All @@ -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(
Expand All @@ -79,7 +80,7 @@ public function it_creates_indexes(): void
);
}

/** @test */
#[Test]
public function it_generates_unique_constraints(): void
{
$this->expectException(QueryException::class);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/TimeRangeConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/RangesCanonizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '(', ')');
Expand Down Expand Up @@ -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');
Expand Down
13 changes: 7 additions & 6 deletions tests/Unit/RangesJsonSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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', '[', ']');
Expand All @@ -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', '[', ']');
Expand All @@ -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, '[', ']');
Expand All @@ -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, '[', ']');
Expand All @@ -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');
Expand Down
13 changes: 7 additions & 6 deletions tests/Unit/RangesSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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', '[', ']');
Expand All @@ -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', '[', ']');
Expand All @@ -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, '[', ']');
Expand All @@ -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, '[', ']');
Expand All @@ -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');
Expand Down
Loading
Loading