Example #1
0
 public function test_if_tag_can_be_persisted()
 {
     $tag = Tag::create(['name' => 'Tag 1']);
     $this->assertEquals('Tag 1', $tag->name);
     $tag = Tag::all()->first();
     $this->assertEquals('Tag 1', $tag->name);
     $this->assertEquals('tag-1', $tag->slug);
 }
Example #2
0
 public function test_can_restore_rows_from_deleted()
 {
     $tag = Tag::create(['name' => 'Tag Test']);
     $tag->delete();
     $tag->restore();
     $tag = Tag::find(1);
     $this->assertEquals(1, $tag->id);
     $this->assertEquals('Tag Test', $tag->name);
 }
Example #3
0
 public function test_destroy_category()
 {
     $category = Tag::create(['name' => 'Tag Destroy']);
     $this->actingAs($this->getUser())->visit('/admin/tags')->see('Tag Destroy')->see('Delete');
     $this->actingAs($this->getUser())->visit('/admin/tags/destroy/' . $category->id)->seePageIs('/admin/tags')->dontSee('Tag Destroy');
 }
Example #4
0
 public function test_can_add_tags_to_posts()
 {
     $post = Post::create(['title' => 'My Post', 'content' => 'My content']);
     $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);
 }