Hello.
I have created small unit test to test a post route to my API.
However the unit tests return 500 on it and never hits the controller and IDK why :(
The error:
[previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'perparson_test.test_lar_App\\CrmCompanyType' doesn't exist at /home/kbuczynski/Documents/projects/PerParsonV2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:67) [stacktrace]
My route looks like this
Route::namespace('Api\Crm')
->group(function () {
Route::group(['prefix' => 'crm', 'middleware' => 'auth:api'], function () {
Route::group(['prefix' => 'type'], function () {
Route::get('/', 'CrmCompanyTypeController@index')
->name('crm_type_index');
Route::get('/{id}', 'CrmCompanyTypeController@show')
->name('crm_type_show');
Route::post('/', 'CrmCompanyTypeController@store')
->name('crm_type_store');
Route::put('/{id}', 'CrmCompanyTypeController@update')
->name('crm_type_update');
Route::delete('/{id}', 'CrmCompanyTypeController@delete')
->name('crm_type_delete');
});
});
});
And test function
public function testPostNewType()
{
$post = ['type' => 'New Test Type'];
$this->actingAs($this->standardUser, 'api')
->postJson('/api/crm/type', $post)
->assertStatus(Code::HTTP_CREATED)
->assertJsonFragment($post);
}