Skip to content

Commit

Permalink
fix(specs): marking property as nullable
Browse files Browse the repository at this point in the history
Merge pull request #273 from AlexTheBest/bugfix/specs-nullable
  • Loading branch information
alexzarbn authored Sep 16, 2024
2 parents 595b547 + 12b7711 commit 306fbff
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Specs/Builders/PropertyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function build(array $column, string $concretePropertyClass): SchemaPrope
/** @var SchemaProperty $property */
$property = new $concretePropertyClass();
$property->name = $column['name'];
$property->nullable = !$column['nullable'];
$property->nullable = $column['nullable'];

return $property;
}
Expand Down
44 changes: 44 additions & 0 deletions tests/Unit/Specs/Builders/PropertyBuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Orion\Tests\Unit\Specs\Builders;

use Orion\Specs\Builders\PathsBuilder;
use Orion\Specs\Builders\PropertyBuilder;
use Orion\Tests\Unit\TestCase;
use Orion\ValueObjects\Specs\Schema\SchemaProperty;

class PropertyBuilderTest extends TestCase
{
/**
* @var PathsBuilder
*/
protected $pathsBuilder;

protected function setUp(): void
{
parent::setUp();

$this->pathsBuilder = app()->make(PathsBuilder::class);
}

/** @test */
public function building_property(): void
{
$column = [
'name' => 'example_column',
'nullable' => true,
];
$concretePropertyClass = 'Orion\ValueObjects\Specs\Schema\SchemaProperty';

$propertyBuilder = new PropertyBuilder();
$property = $propertyBuilder->build($column, $concretePropertyClass);

$this->assertInstanceOf(SchemaProperty::class, $property);
$this->assertEquals($column['name'], $property->name);
$this->assertEquals($column['nullable'], $property->nullable);
}
}


0 comments on commit 306fbff

Please sign in to comment.