Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-w committed Apr 17, 2023
1 parent 7726333 commit 222d714
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Query\Builder as BaseBuilder;
use Mockery as m;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -59,6 +60,7 @@ protected function getRelation()
$related = m::mock(Model::class);
$related->shouldReceive('newCollection')->passthru();
$builder->shouldReceive('getModel')->andReturn($related);
$builder->shouldReceive('getQuery')->andReturn(m::mock(BaseBuilder::class));
$related->shouldReceive('qualifyColumn');
$builder->shouldReceive('join', 'where');

Expand Down
2 changes: 2 additions & 0 deletions tests/Database/DatabaseEloquentHasManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Query\Builder as BaseBuilder;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
Expand Down Expand Up @@ -289,6 +290,7 @@ protected function getRelation()
$builder->shouldReceive('where')->with('table.foreign_key', '=', 1);
$related = m::mock(Model::class);
$builder->shouldReceive('getModel')->andReturn($related);
$builder->shouldReceive('getQuery')->andReturn(m::mock(BaseBuilder::class));
$parent = m::mock(Model::class);
$parent->shouldReceive('getAttribute')->with('id')->andReturn(1);
$parent->shouldReceive('getCreatedAtColumn')->andReturn('created_at');
Expand Down
1 change: 1 addition & 0 deletions tests/Database/DatabaseEloquentHasOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ protected function getRelation()
$this->builder->shouldReceive('where')->with('table.foreign_key', '=', 1);
$this->related = m::mock(Model::class);
$this->builder->shouldReceive('getModel')->andReturn($this->related);
$this->builder->shouldReceive('getQuery')->andReturn(m::mock(BaseBuilder::class));
$this->parent = m::mock(Model::class);
$this->parent->shouldReceive('getAttribute')->with('id')->andReturn(1);
$this->parent->shouldReceive('getAttribute')->with('username')->andReturn('taylor');
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Database/EloquentKeyByTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function postsByDate()
$cast = match (DB::connection()->getDriverName()) {
'mysql', 'sqlite' => 'SUBSTR(created_at, 1, 10)',
'pgsql' => 'SUBSTR(CAST(created_at AS varchar), 1, 10)',
'sqlsrv' => 'SUBSTRING(CAST(created_at AS varchar), 1, 10)'
'sqlsrv' => 'CONVERT(date, created_at)'
};
return $this->hasMany(Post::class)->keyBy(DB::raw($cast));
}
Expand Down

0 comments on commit 222d714

Please sign in to comment.