public function test_entity_creation()
{
-
// Test Creation
$book = $this->bookCreation();
$chapter = $this->chapterCreation($book);
->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([
$book = factory(Book::class)->make([
'name' => 'My First Book'
]);
-
- $this->uploadImage('test-image.jpg', 0);
$this->asAdmin()
->visit('/books')
// Choose to create a book
// Fill out form & save
->type($book->name, '#name')
->type($book->description, '#description')
- ->press('Select Image')
- ->click('test-image.jpg')
- ->press('Select Image')
->press('Save Book')
// Check it redirects correctly
->seePageIs('/books/my-first-book')
->see($book->name)->see($book->description);
- $book = factory(Book::class)->latest();
- $this->assertDatabaseHas('images', [
- 'id' => $book->image
- ]);
-
// Ensure duplicate names are given different slugs
$this->asAdmin()
->visit('/books/create')
->type($book->name, '#name')
->type($book->description, '#description')
- ->press('Select Image')
- ->click('test-image.jpg')
- ->press('Select Image')
->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");
->seeInElement('#recently-updated-pages', $page->name);
}
- public function test_recently_created_pages_on_home()
+ public function test_slug_multi_byte_lower_casing()
{
- $entityChain = $this->createEntityChainBelongingToUser($this->getEditor());
- $this->asAdmin()->visit('/')
- ->seeInElement('#recently-created-pages', $entityChain['page']->name);
- }
+ $entityRepo = app(EntityRepo::class);
+ $book = $entityRepo->createFromInput('book', [
+ 'name' => 'КНИГА'
+ ]);
- protected function uploadImage($name, $uploadedTo = 0)
- {
- $file = $this->getTestImage($name);
- $this->call('POST', '/images/gallery/upload', ['uploaded_to' => $uploadedTo], [], ['file' => $file], []);
- return $this->getTestImagePath('gallery', $name);
+ $this->assertEquals('книга', $book->slug);
}
- protected function getTestImage($fileName)
- {
- return new \Illuminate\Http\UploadedFile(base_path('tests/test-data/test-image.jpg'), $fileName, 'image/jpeg', 5238);
- }
- protected function getTestImagePath($type, $fileName)
+ public function test_slug_format()
{
- return '/uploads/images/' . $type . '/' . Date('Y-m-M') . '/' . $fileName;
+ $entityRepo = app(EntityRepo::class);
+ $book = $entityRepo->createFromInput('book', [
+ 'name' => 'PartA / PartB / PartC'
+ ]);
+
+ $this->assertEquals('parta-partb-partc', $book->slug);
}
-}
+}