I am trying to test that a user can create a pin but I keep getting this error.
1) Tests\Feature\CreatePinTest::an_authorized_user_can_create_a_pin
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/pins'
+'http://localhost/pins/1'
here is my test
/** @test */
function an_authorized_user_can_create_a_pin()
{
$this->withoutExceptionHandling();
$user = create('App\User');
$this->be($user);
$pin = make('App\Pin');
$response = $this->post('/pins/create', $pin->toArray());
$response->assertRedirect(route('pins.show', ['id' => $pin->id]));
$response->assertSee($pin->title)
->assertSee($pin->link);
}
Here is the routes
Route::post('/pins/create', 'PinsController@store');
Route::get('/pins/{pin}', 'PinsController@show')->name('pins.show');
Here is the controller
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required|max:200',
'link' => 'required|max:255'
]);
$pin = new Pin();
$pin->title = $request->title;
$pin->link = $request->link;
$pin->user_id = auth()->id();
$pin->save();
return redirect("/pins/{$pin->id}");
}
What I want to happen is what the error Actually gets but I can't figure out how to adjust my test for that.
Aucun commentaire:
Enregistrer un commentaire