Thursday, March 30, 2017

Laravel 5.2 Unit Tests error: BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::make()

I'm trying to set-up PHPunit with Laravel 5.2. I followed the documentation for a simple unit test, however every test throws the same error:

1) CreateAccountTest::testCreateUserWithInvalidEmail BadMethodCallException: Call to undefined method Illuminate\Database\Query\Builder::make()

/some/path/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2405 /some/path/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1426 /some/path/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3526 /some/path/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:504 /some/path/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:504 /some/path/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:73 /some/path/tests/UnitTests/CreateAccountTest.php:32

My unit tests all look similar to this, except it's asserting a different property every time:

public function testCreateUserWithInvalidEmail() {
    $this->body['email'] = 'this_is_not_a_valid_email_address';

    $this->json('POST', '/profile/create', $this->body)
         ->assertResponseStatus(400);
}

Line 32 as stated by the stacktrace is the following line:

 $this->json('POST', '/profile/create', $this->body)
             ->assertResponseStatus(400);

It all seems very straightforward according to the docs and I have no idea what is happening here.



via SolveSoul

Advertisement