public function test_edit_post() { $post = Post::create(['title' => 'Post Edit', 'content' => 'Post Content']); $this->actingAs($this->getUser())->visit('/admin/posts')->see('Post Edit')->see('Delete'); $this->actingAs($this->getUser())->visit('/admin/posts/edit/' . $post->id)->see('Update Post')->see('Post Edit')->see('Post Content')->type('Post Edit Update', 'title')->type('Post Content Update', 'content')->press('Submit')->seePageIs('/admin/posts')->see('Post Edit Update'); $post = Post::find($post->id); $this->assertEquals('Post Edit Update', $post->title); $this->assertEquals('Post Content Update', $post->content); }
public function test_can_add_tags_to_posts() { $post = Post::create(['title' => 'My Post', 'content' => 'My content', 'slug' => 'my-post']); $tag1 = Tag::create(['name' => 'Tag 1']); $tag2 = Tag::create(['name' => 'Tag 2']); $tag1->posts()->save($post); $tag2->posts()->save($post); $this->assertCount(1, Post::all()); $this->assertEquals('My Post', $tag1->posts->first()->title); $this->assertEquals('My Post', $tag2->posts->first()->title); $tags = Post::find(1)->tags; $this->assertCount(2, $tags); $this->assertEquals('Tag 1', $tags[0]->name); $this->assertEquals('Tag 2', $tags[1]->name); }
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); }