Skip to content

Commit

Permalink
ITT: Laravel 5.3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivanov committed Sep 7, 2017
1 parent 8f1a73d commit dbd1cde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
10 changes: 2 additions & 8 deletions src/Asserts/DatabaseAsserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@ protected function dontSeeDatabaseTable($table)

protected function seeInDatabaseMany($table, array $rows)
{
/* @laravel-versions */
$assert = method_exists($this, 'assertDatabaseHas') ? 'assertDatabaseHas' : 'seeInDatabase';

foreach ($rows as $row) {
$this->$assert($table, $row);
$this->seeInDatabase($table, $row);
}

return $this;
}

protected function dontSeeInDatabaseMany($table, array $rows)
{
/* @laravel-versions */
$assert = method_exists($this, 'assertDatabaseMissing') ? 'assertDatabaseMissing' : 'dontSeeInDatabase';

foreach ($rows as $row) {
$this->$assert($table, $row);
$this->dontSeeInDatabase($table, $row);
}

return $this;
Expand Down
9 changes: 2 additions & 7 deletions src/Asserts/EloquentAsserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ protected function assertEloquentHasMany($class, $relation)
$parentKey = $hasManyRelation->getParent()->getKeyName();
$childModel = $hasManyRelation->getRelated();
$childKey = $childModel->getKeyName();

/* @laravel-versions */
$childForeignKey = method_exists($hasManyRelation, 'getForeignKeyName')
? $hasManyRelation->getForeignKeyName() : last(explode('.', $hasManyRelation->getForeignKey()));
$childForeignKey = last(explode('.', $hasManyRelation->getForeignKey()));

$parent = factory($class)->create();
$children = factory(get_class($childModel), 3)->create([$childForeignKey => $parent->{$parentKey}]);
Expand Down Expand Up @@ -127,9 +124,7 @@ protected function assertEloquentHasCreateManyFor($class, $relation, $createMany
->make()
->toArray()
);

/* @laravel-versions */
$children = is_array($children) ? collect($children) : $children;
$children = collect($children);

$this->assertCollectionsEqual($children, $parent->{$relation}, $childKey);
}
Expand Down

0 comments on commit dbd1cde

Please sign in to comment.