Skip to content

Commit

Permalink
[5.2] Correct formatting of updatedAt timestamp when calling touch() …
Browse files Browse the repository at this point in the history
…on BelongsToMany (#13799)

* use correctly formatted timestamp string for touch update on BelongsToMany relationship

* fix test

* make mock return correct typed test data
  • Loading branch information
jaimemasson authored and taylorotwell committed Jun 1, 2016
1 parent 8244d24 commit 5add162
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ public function updatedAt()
*/
public function getRelatedFreshUpdate()
{
return [$this->related->getUpdatedAtColumn() => $this->related->freshTimestamp()];
return [$this->related->getUpdatedAtColumn() => $this->related->freshTimestampString()];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Database/DatabaseEloquentBelongsToManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,13 @@ public function testTouchMethodSyncsTimestamps()
{
$relation = $this->getRelation();
$relation->getRelated()->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at');
$relation->getRelated()->shouldReceive('freshTimestamp')->andReturn(100);
$relation->getRelated()->shouldReceive('freshTimestampString')->andReturn('100');
$relation->getRelated()->shouldReceive('getQualifiedKeyName')->andReturn('table.id');
$relation->getQuery()->shouldReceive('select')->once()->with('table.id')->andReturn($relation->getQuery());
$relation->getQuery()->shouldReceive('pluck')->once()->with('id')->andReturn([1, 2, 3]);
$relation->getRelated()->shouldReceive('newQuery')->once()->andReturn($query = m::mock('StdClass'));
$query->shouldReceive('whereIn')->once()->with('id', [1, 2, 3])->andReturn($query);
$query->shouldReceive('update')->once()->with(['updated_at' => 100]);
$query->shouldReceive('update')->once()->with(['updated_at' => '100']);

$relation->touch();
}
Expand Down

0 comments on commit 5add162

Please sign in to comment.