tests/Feature/CommentsControllerTest.php
/**
     * Test the store method for saving a new comment.
     */
Test the store method for saving a new comment.
Test the store method for saving a new comment .
public function testStore(): void
    {
        $post = factory(Post::class)->create();
        $url = route('blogetc.comments.add_new_comment', $post->slug);
        $params = [
            'comment' => $this->faker->sentence,
            'author_name' => $this->faker->name,
            'author_email' => $this->faker->safeEmail,
            'author_website' => 'http://'.$this->faker->safeEmailDomain,
        ];
        $response = $this->postJson($url, $params);
        $response->assertCreated();
        $this->withoutExceptionHandling();
        $postResponse = $this->get(route('blogetc.show', $post->slug));
        $postResponse->assertSee($params['comment']);
    }
public function testStore ( ) : void { $ post = factory ( Post :: class ) -> create ( ) ; $ url = route ( 'blogetc.comments.add_new_comment' , $ post -> slug ) ; $ params = [ 'comment' => $ this -> faker -> sentence , 'author_name' => $ this -> faker -> name , 'author_email' => $ this -> faker -> safeEmail , 'author_website' => 'http://' . $ this -> faker -> safeEmailDomain , ] ; $ response = $ this -> postJson ( $ url , $ params ) ; $ response -> assertCreated ( ) ; $ this -> withoutExceptionHandling ( ) ; $ postResponse = $ this -> get ( route ( 'blogetc.show' , $ post -> slug ) ) ; $ postResponse -> assertSee ( $ params [ 'comment' ] ) ; }
Test the store method for saving a new comment.
Test the store method for saving a new comment .
// Test can see the comment on the post page and therefore saved in the database.