I am writting a Test Case.
Lets say there is a Threads model with fields: user_id, title, body
So to test wheather submitting the Thread works, I am doing this:
$user = factory('App\User')->create();
$thread = factory('App\Thread')->make(['user_id' => $user->id]);
$this->post('/threads', $thread->toArray());
$this->get('/thread/'.$thread->id)
->assertSee($thread->title)
But I have yet another field that I want to post along with the thread which is not part of the thread model.
eg.
community => 'some_community'
So how do I append another field before posting the array to /threads.
How can I append key value pair to the result of make() ???
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire