Skip to content

Commit

Permalink
[5.5] Revert model BadMethodException changes (#21929)
Browse files Browse the repository at this point in the history
*      revert model BadMethodException changes

*    fix style
  • Loading branch information
themsaid authored and taylorotwell committed Nov 2, 2017
1 parent 437114e commit ada03c8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
9 changes: 1 addition & 8 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
18 changes: 0 additions & 18 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ada03c8

Please sign in to comment.