X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ebf78d49a866fb61f908111225ced91946f6d3ef..refs/pull/651/head:/tests/Entity/EntityTest.php diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index 07f1926c5..4d4e0e6cd 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -11,7 +11,6 @@ class EntityTest extends BrowserKitTest public function test_entity_creation() { - // Test Creation $book = $this->bookCreation(); $chapter = $this->chapterCreation($book); @@ -83,6 +82,27 @@ class EntityTest extends BrowserKitTest ->see($firstChapter->name); } + public function test_toggle_book_view() + { + $editor = $this->getEditor(); + setting()->putUser($editor, 'books_view_type', 'grid'); + + $this->actingAs($editor) + ->visit('/books') + ->pageHasElement('.featured-image-container') + ->submitForm('List View') + // Check redirection. + ->seePageIs('/books') + ->pageNotHasElement('.featured-image-container'); + + $this->actingAs($editor) + ->visit('/books') + ->submitForm('Grid View') + ->seePageIs('/books') + ->pageHasElement('.featured-image-container'); + + } + public function pageCreation($chapter) { $page = factory(Page::class)->make([ @@ -156,7 +176,7 @@ class EntityTest extends BrowserKitTest ->type($book->name, '#name') ->type($book->description, '#description') ->press('Save Book'); - + $expectedPattern = '/\/books\/my-first-book-[0-9a-zA-Z]{3}/'; $this->assertRegExp($expectedPattern, $this->currentUri, "Did not land on expected page [$expectedPattern].\n"); @@ -257,4 +277,25 @@ class EntityTest extends BrowserKitTest ->seeInElement('#recently-updated-pages', $page->name); } + public function test_slug_multi_byte_lower_casing() + { + $entityRepo = app(EntityRepo::class); + $book = $entityRepo->createFromInput('book', [ + 'name' => 'КНИГА' + ]); + + $this->assertEquals('книга', $book->slug); + } + + + public function test_slug_format() + { + $entityRepo = app(EntityRepo::class); + $book = $entityRepo->createFromInput('book', [ + 'name' => 'PartA / PartB / PartC' + ]); + + $this->assertEquals('parta-partb-partc', $book->slug); + } + }