Skip to content
Permalink
Browse files

Structure::getBelongsToReference() return value fix

  • Loading branch information...
Miloslav Hůla authored and dg committed Apr 11, 2019
1 parent a740e3f commit cf962df6c9a5a7126a89a2ec652c820e6cd7cf36
Showing with 11 additions and 1 deletion.
  1. +3 −1 src/Database/Structure.php
  2. +8 −0 tests/Database/Structure.phpt
@@ -148,7 +148,9 @@ public function getBelongsToReference(string $table, string $column = null): ?ar
if ($column) {
$column = strtolower($column);
return $this->structure['belongsTo'][$table][$column] ?? null;
return isset($this->structure['belongsTo'][$table][$column])
? [$this->structure['belongsTo'][$table][$column], $column]
: null;
} else {
return $this->structure['belongsTo'][$table] ?? [];
@@ -173,6 +173,14 @@ class StructureTestCase extends TestCase
'tag_id' => 'tags',
'book_id' => 'Books',
], $this->structure->getBelongsToReference('books_x_tags'));
Assert::same(
['Books', 'book_id'],
$this->structure->getBelongsToReference('books_x_tags', 'book_id')
);
Assert::null($this->structure->getBelongsToReference('books_x_tags', 'non_exist'));
}

0 comments on commit cf962df

Please sign in to comment.
You can’t perform that action at this time.