dimanche 31 juillet 2016

test store method in Laravel

I am trying to test the store method in the simplest way possible. I don't necessarily need Mockery, I'm fine with actually adding to the database. I couldn't get Mockery to work anyway.

Now I have this:

public function testStore()
{
    $data = ['name' => 'TestClub', 'code' => 'TCL'];
    Input::replace($data);
    $this->route('POST', 'clubs.store', $Input::all());
    $this->assertResponseOk();
}

This is my controller method:

public function store() {
    $validator = Validator::make($data = Input::all(), Club::$rules);
    if ($validator->fails()) {
        return Redirect::back()->withErrors($validator)->withInput();
    }
    Club::create($data);
    return redirect(Session::get('backUrl'));
}

I get a return code 500, I have no idea why. Can I somehow see the request it's sending?

I am using Laravel 5.0

Aucun commentaire:

Enregistrer un commentaire