Example #1
0
 public function test_can_restore_deleted_all_from_relationship()
 {
     $post = Post::create(['title' => 'Post test', 'content' => 'Content post']);
     $comment1 = Comment::create(['content' => 'Content Test 1', 'post_id' => $post->id]);
     $comment2 = Comment::create(['content' => 'Content Test 2', 'post_id' => $post->id]);
     $comment1->delete();
     $comment2->delete();
     $post->comments()->restore();
     $this->assertCount(2, $post->comments()->get());
 }
Example #2
0
 public function test_can_add_posts_to_tags()
 {
     $tag = Tag::create(['name' => 'Tag Test']);
     $post1 = Post::create(['title' => 'My post 1', 'content' => 'My content 1', 'slug' => 'my-post-1']);
     $post2 = Post::create(['title' => 'My post 2', 'content' => 'My content 2', 'slug' => 'my-post-2']);
     $post1->tags()->save($tag);
     $post2->tags()->save($tag);
     $this->assertCount(1, Tag::all());
     $this->assertEquals('Tag Test', $post1->tags->first()->name);
     $this->assertEquals('Tag Test', $post2->tags->first()->name);
     $posts = Tag::find(1)->posts;
     $this->assertCount(2, $posts);
     $this->assertEquals('My post 1', $posts[0]->title);
     $this->assertEquals('My post 2', $posts[1]->title);
 }
Example #3
0
 public function test_can_add_posts_to_categories()
 {
     $category = Category::create(['name' => 'Category Test', 'active' => true]);
     $post1 = Post::create(['title' => 'My post 1', 'content' => 'My content 1']);
     $post2 = Post::create(['title' => 'My post 2', 'content' => 'My content 2']);
     $post1->categories()->save($category);
     $post2->categories()->save($category);
     $this->assertCount(1, Category::all());
     $this->assertEquals('Category Test', $post1->categories->first()->name);
     $this->assertEquals('Category Test', $post2->categories->first()->name);
     $posts = Category::find(1)->posts;
     $this->assertCount(2, $posts);
     $this->assertEquals('My post 1', $posts[0]->title);
     $this->assertEquals('My post 2', $posts[1]->title);
 }
 public function deleted()
 {
     $posts = Post::onlyTrashed()->get();
     return view('codepost::deleted', compact('posts'));
 }
Example #5
0
 public function test_destroy_post()
 {
     $post = Post::create(['title' => 'Post Destroy', 'content' => 'Post Content']);
     $this->actingAs($this->getUser())->visit('/admin/posts')->see('Post Destroy')->see('Delete');
     $this->actingAs($this->getUser())->visit('/admin/posts/destroy/' . $post->id)->seePageIs('/admin/posts')->dontSee('Post Destroy');
 }
Example #6
0
 public function test_can_restore_rows_from_deleted()
 {
     $post = Post::create(['title' => 'Post test', 'content' => 'Content post']);
     $post->delete();
     $post->restore();
     $post = Post::find(1);
     $this->assertEquals(1, $post->id);
     $this->assertEquals('Post test', $post->title);
 }