Skip to content

Commit

Permalink
Add test to assure generateTagSlug() works like str_slug()
Browse files Browse the repository at this point in the history
  • Loading branch information
darron1217 committed Feb 27, 2018
1 parent b809722 commit 8e8bc6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Modules/Tag/Tests/Integration/TaggableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Modules\Tag\Tests\Integration;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Modules\Page\Entities\Page;
use Modules\Page\Repositories\PageRepository;
use Modules\Tag\Repositories\TagRepository;
Expand Down Expand Up @@ -132,6 +133,18 @@ public function it_gets_all_tags_for_a_namespace()
$this->assertCount(3, Page::allTags()->get());
}

/** @test */
public function it_generates_slug_like_original_str_slug()
{
$page = $this->createPage();

$this->assertEquals(Str::slug('hello world'), $page->generateTagSlug('hello world'));
$this->assertEquals(Str::slug('hello world'), $page->generateTagSlug('hello-world'));
$this->assertEquals(Str::slug('hello_world'), $page->generateTagSlug('hello_world'));
$this->assertEquals(Str::slug('hello_world', '_'), $page->generateTagSlug('hello_world', '_'));
$this->assertEquals(Str::slug('user@host'), $page->generateTagSlug('user@host'));
}

/** @test */
public function it_gets_pages_with_non_latin_tags()
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Tag/Traits/TaggableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected function getEntityClassName()
/**
* {@inheritdoc}
*/
protected function generateTagSlug($name, $separator = '-')
public function generateTagSlug($name, $separator = '-')
{
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
Expand Down

0 comments on commit 8e8bc6d

Please sign in to comment.