diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php index 2fe3f0ba6b6b..ba20e42c68b8 100755 --- a/src/Illuminate/Database/Query/Builder.php +++ b/src/Illuminate/Database/Query/Builder.php @@ -2172,7 +2172,7 @@ public function updateOrInsert(array $attributes, array $values = []) return $this->insert(array_merge($attributes, $values)); } - return (bool) $this->where($attributes)->take(1)->update($values); + return (bool) $this->take(1)->update($values); } /** diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index 3f36254cce8f..fb7a1ae2e826 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -1286,7 +1286,7 @@ public function testUpdateOrInsertMethod() m::mock('Illuminate\Database\Query\Processors\Processor'), ]); - $builder->shouldReceive('where')->twice()->with(['email' => 'foo'])->andReturn(m::self()); + $builder->shouldReceive('where')->once()->with(['email' => 'foo'])->andReturn(m::self()); $builder->shouldReceive('exists')->once()->andReturn(true); $builder->shouldReceive('take')->andReturnSelf(); $builder->shouldReceive('update')->once()->with(['name' => 'bar'])->andReturn(1);