samedi 30 mars 2019

How can I create a polymophic relation factory so that I can use it on my phpunit tests?

I have articles table and comments table. comments table includes commentable_id commentable_type and body. I tried the code below on my testcase which doesn't seem right. With this one I cannot create multiple comments.

/** @test */
    public function an_authenticated_user_can_comment_a_post(){

        $user = $this->signIn();

        $article = factory('App\Article')->create();

        $this->post("article/{$article->slug}/comment", [
            'comment' => $this->faker->sentence,
        ]);

        $this->assertCount(1, $article->comments);

    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OwzWeG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire