Adding additional tests to cover the removal of multiple tags at once. And...

Adding additional tests to cover the removal of multiple tags at once. And making sure all tag links have been removed upon removing an entity.
parent 50d92d71
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Modules\Tag\Tests\Integration; namespace Modules\Tag\Tests\Integration;
use Illuminate\Support\Facades\DB;
use Modules\Page\Entities\Page; use Modules\Page\Entities\Page;
use Modules\Page\Repositories\PageRepository; use Modules\Page\Repositories\PageRepository;
use Modules\Tag\Repositories\TagRepository; use Modules\Tag\Repositories\TagRepository;
...@@ -63,13 +64,38 @@ class TaggableTraitTest extends BaseTestCase ...@@ -63,13 +64,38 @@ class TaggableTraitTest extends BaseTestCase
{ {
$this->createPage(['original tag']); $this->createPage(['original tag']);
$page = $this->page->findHomepage(); $page = $this->page->find(1);
$page->setTags(['my first tag']); $page->setTags(['my first tag']);
$page = $this->page->findHomepage();
$this->assertCount(1, $page->tags); $this->assertCount(1, $page->tags);
} }
/** @test */
public function it_can_remove_all_tags()
{
$this->createPage(['original tag', 'tag2', 'tag3', ]);
$page = $this->page->find(1);
$this->page->update($page, ['tags' => []]);
$page = $page->fresh();
$this->assertCount(0, $page->tags);
}
/** @test */
public function it_removes_all_tag_links_when_removing_entity()
{
$this->createPage(['original tag', 'tag2', 'tag3', ]);
$page = $this->page->find(1);
$pageId = $page->id;
$this->page->destroy($page);
$count = DB::table('tag__tagged')->where('taggable_id', $pageId)->get();
$this->assertCount(0, $count);
}
/** @test */ /** @test */
public function it_can_get_pages_with_one_of_specified_tags() public function it_can_get_pages_with_one_of_specified_tags()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment