From b21c9b19510449b9a85fea5225ee6bbbb282611f Mon Sep 17 00:00:00 2001 From: Jaime Masson Date: Wed, 1 Jun 2016 00:30:50 -0700 Subject: [PATCH 1/3] use correctly formatted timestamp string for touch update on BelongsToMany relationship --- src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index 02bcd723d230..a71b022950d6 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -1242,7 +1242,7 @@ public function updatedAt() */ public function getRelatedFreshUpdate() { - return [$this->related->getUpdatedAtColumn() => $this->related->freshTimestamp()]; + return [$this->related->getUpdatedAtColumn() => $this->related->freshTimestampString()]; } /** From 57bf45b0c7e7bffc1227549cd196819bb1a03521 Mon Sep 17 00:00:00 2001 From: Jaime Masson Date: Wed, 1 Jun 2016 01:01:48 -0700 Subject: [PATCH 2/3] fix test --- tests/Database/DatabaseEloquentBelongsToManyTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/DatabaseEloquentBelongsToManyTest.php b/tests/Database/DatabaseEloquentBelongsToManyTest.php index 5b520cecfdd1..661bba805106 100755 --- a/tests/Database/DatabaseEloquentBelongsToManyTest.php +++ b/tests/Database/DatabaseEloquentBelongsToManyTest.php @@ -521,7 +521,7 @@ 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]); From 41345c60db46091af9aabc3a88ca44679c2abc30 Mon Sep 17 00:00:00 2001 From: Jaime Masson Date: Wed, 1 Jun 2016 01:28:13 -0700 Subject: [PATCH 3/3] make mock return correct typed test data --- tests/Database/DatabaseEloquentBelongsToManyTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Database/DatabaseEloquentBelongsToManyTest.php b/tests/Database/DatabaseEloquentBelongsToManyTest.php index 661bba805106..e49663836fa0 100755 --- a/tests/Database/DatabaseEloquentBelongsToManyTest.php +++ b/tests/Database/DatabaseEloquentBelongsToManyTest.php @@ -521,13 +521,13 @@ public function testTouchMethodSyncsTimestamps() { $relation = $this->getRelation(); $relation->getRelated()->shouldReceive('getUpdatedAtColumn')->andReturn('updated_at'); - $relation->getRelated()->shouldReceive('freshTimestampString')->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(); }