tests/Feature/Admin/ManagePostsControllerTest.php
/**
     * Test that new posts can be created, and associated to a category.
     */
Test that new posts can be created, and associated to a category.
Test that new posts can be created and associated to a category .
public function testStoreWithInvalidCategory(): void
    {
        $this->beAdminUser();
        $invalidCategoryID = 1000;
        $params = [
            'title' => $this->faker->sentence,
            'post_body' => $this->faker->paragraph,
            'meta_desc' => $this->faker->paragraph,
            'short_description' => $this->faker->paragraph,
            'category' => [$invalidCategoryID => '1'],
        ];
        $response = $this->post(route('blogetc.admin.store_post'), $params);
        $response->assertSessionHasErrors('category');
    }
public function testStoreWithInvalidCategory ( ) : void { $ this -> beAdminUser ( ) ; $ invalidCategoryID = 1000 ; $ params = [ 'title' => $ this -> faker -> sentence , 'post_body' => $ this -> faker -> paragraph , 'meta_desc' => $ this -> faker -> paragraph , 'short_description' => $ this -> faker -> paragraph , 'category' => [ $ invalidCategoryID => '1' ] , ] ; $ response = $ this -> post ( route ( 'blogetc.admin.store_post' ) , $ params ) ; $ response -> assertSessionHasErrors ( 'category' ) ; }
Test that new posts can be created, and associated to a category.
Test that new posts can be created and associated to a category .