namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Http\Request;
use DMO\SavingsBond\Models\Offer;
use Carbon\Carbon;
class BondOfferCRUDTest extends TestCase
{
use DatabaseMigrations;
/**
* A basic unit test example.
*
* @return void
*/
public function test_bond_offer_Model_CRUD()
{
/*
//Given we have task in the database
$task = factory('App\Task')->create();
//When user visit the tasks page
$response = $this->get('/tasks');
//He should be able to read the task
$response->assertSee($task->title);*/
$bondOffer_Data = Offer::create([
'organization_id' => '1',
'status' => 'app',
'offer_title' => 'Apollos Geofrey',
'price_per_unit' => '100'
]);
$bondOffer_DB = Offer::find($bondOffer_Data->id);
$this->assertEquals(
$bondOffer_Data['offer_title'],
$bondOffer_DB->offer_title
);
}
}
I am running a phpunit test, to test a model, the error has kept me stocked. See complete error below:
Illuminate\Contracts\Container\BindingResolutionException
Target class [request] does not exist.
at vendor/laravel/framework/src/Illuminate/Container/Container.php:879
Each time i run php artisan test, the error is returned. Please, I don't know what am I doing wrong, i need an assistance on how to solve this problem
CodePudding user response:
Its a error of request class error, you just need to add this class use Illuminate\Http\Request; inside the controller that you calling while hitting the route.
CodePudding user response:
This was resolved, i realized the model was using a Trait containing Organization Constraints which somehow alters the Model.