Skip to content

Commit 306fbff

Browse files
authored
fix(specs): marking property as nullable
Merge pull request #273 from AlexTheBest/bugfix/specs-nullable
2 parents 595b547 + 12b7711 commit 306fbff

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/Specs/Builders/PropertyBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function build(array $column, string $concretePropertyClass): SchemaPrope
1919
/** @var SchemaProperty $property */
2020
$property = new $concretePropertyClass();
2121
$property->name = $column['name'];
22-
$property->nullable = !$column['nullable'];
22+
$property->nullable = $column['nullable'];
2323

2424
return $property;
2525
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Orion\Tests\Unit\Specs\Builders;
6+
7+
use Orion\Specs\Builders\PathsBuilder;
8+
use Orion\Specs\Builders\PropertyBuilder;
9+
use Orion\Tests\Unit\TestCase;
10+
use Orion\ValueObjects\Specs\Schema\SchemaProperty;
11+
12+
class PropertyBuilderTest extends TestCase
13+
{
14+
/**
15+
* @var PathsBuilder
16+
*/
17+
protected $pathsBuilder;
18+
19+
protected function setUp(): void
20+
{
21+
parent::setUp();
22+
23+
$this->pathsBuilder = app()->make(PathsBuilder::class);
24+
}
25+
26+
/** @test */
27+
public function building_property(): void
28+
{
29+
$column = [
30+
'name' => 'example_column',
31+
'nullable' => true,
32+
];
33+
$concretePropertyClass = 'Orion\ValueObjects\Specs\Schema\SchemaProperty';
34+
35+
$propertyBuilder = new PropertyBuilder();
36+
$property = $propertyBuilder->build($column, $concretePropertyClass);
37+
38+
$this->assertInstanceOf(SchemaProperty::class, $property);
39+
$this->assertEquals($column['name'], $property->name);
40+
$this->assertEquals($column['nullable'], $property->nullable);
41+
}
42+
}
43+
44+

0 commit comments

Comments
 (0)