Skip to content

Commit 91b7817

Browse files
Add test for non-nullable field
1 parent 1ab9bde commit 91b7817

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Models/ForeignRelationship.php

-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ public function toArray()
435435
*/
436436
public static function get(array $options)
437437
{
438-
439438
if (!array_key_exists('type', $options) || !array_key_exists('params', $options) || !array_key_exists('name', $options)) {
440439

441440
if(count($options) >= 3) {

tests/ForeignRelationTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,14 @@ public function testAbilityToCreateRelationForSingleField()
1818
$relation = ForeignRelationship::fromString("name:fooModel;is-nullable:true;data-type:varchar;foreign-relation:assets#hasMany#App\\Models\\Asset|category_id|id");
1919

2020
// TO DO, asset that the relation is created successfully!
21+
$this->assertTrue($relation instanceof ForeignRelationship);
22+
}
23+
24+
public function testAbilityToCreateRelationForSingleFieldNotNullable()
25+
{
26+
$relation = ForeignRelationship::fromString("name:fooModel;data-type:varchar;foreign-relation:assets#hasMany#App\\Models\\Asset|category_id|id");
27+
28+
// TO DO, asset that the relation is created successfully!
29+
$this->assertTrue($relation instanceof ForeignRelationship);
2130
}
2231
}

0 commit comments

Comments
 (0)