diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 905c486e8332..708aa7a6e130 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -5,7 +5,6 @@ use Exception; use ArrayAccess; use JsonSerializable; -use BadMethodCallException; use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\Contracts\Support\Jsonable; @@ -1436,13 +1435,7 @@ public function __call($method, $parameters) return $this->$method(...$parameters); } - try { - return $this->newQuery()->$method(...$parameters); - } catch (BadMethodCallException $e) { - throw new BadMethodCallException( - sprintf('Call to undefined method %s::%s()', get_class($this), $method) - ); - } + return $this->newQuery()->$method(...$parameters); } /** diff --git a/tests/Database/DatabaseEloquentModelTest.php b/tests/Database/DatabaseEloquentModelTest.php index 3faa6e473670..a427a8d4d0d2 100755 --- a/tests/Database/DatabaseEloquentModelTest.php +++ b/tests/Database/DatabaseEloquentModelTest.php @@ -453,24 +453,6 @@ public function testFromDateTime() $this->assertEquals('2015-04-17 22:59:01', $model->fromDateTime($value)); } - /** - * @expectedException \BadMethodCallException - * @expectedExceptionMessage Call to undefined method Illuminate\Tests\Database\EloquentModelStub::badMethod() - */ - public function testBadMethodCallException() - { - $conn = m::mock('Illuminate\Database\Connection'); - $grammar = m::mock('Illuminate\Database\Query\Grammars\Grammar'); - $processor = m::mock('Illuminate\Database\Query\Processors\Processor'); - $conn->shouldReceive('getQueryGrammar')->once()->andReturn($grammar); - $conn->shouldReceive('getPostProcessor')->once()->andReturn($processor); - EloquentModelStub::setConnectionResolver($resolver = m::mock('Illuminate\Database\ConnectionResolverInterface')); - $resolver->shouldReceive('connection')->andReturn($conn); - - $model = new EloquentModelStub; - $model->badMethod(); - } - public function testInsertProcess() { $model = $this->getMockBuilder('Illuminate\Tests\Database\EloquentModelStub')->setMethods(['newQueryWithoutScopes', 'updateTimestamps', 'refresh'])->getMock();