Example #1
0
 public function bookCreation()
 {
     $book = factory(\BookStack\Book::class)->make(['name' => 'My First Book']);
     $this->asAdmin()->visit('/books')->click('Add new book')->seePageIs('/books/create')->type($book->name, '#name')->type($book->description, '#description')->press('Save Book')->seePageIs('/books/my-first-book')->see($book->name)->see($book->description);
     // Ensure duplicate names are given different slugs
     $this->asAdmin()->visit('/books/create')->type($book->name, '#name')->type($book->description, '#description')->press('Save Book')->seePageIs('/books/my-first-book-2');
     $book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
     return $book;
 }
Example #2
0
 public function bookCreation()
 {
     $book = factory(\BookStack\Book::class)->make(['name' => 'My First Book']);
     $this->asAdmin()->visit('/books')->click('Add new book')->seePageIs('/books/create')->type($book->name, '#name')->type($book->description, '#description')->press('Save Book')->seePageIs('/books/my-first-book')->see($book->name)->see($book->description);
     // Ensure duplicate names are given different slugs
     $this->asAdmin()->visit('/books/create')->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");
     $book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
     return $book;
 }
Example #3
0
 public function test_chapter_move()
 {
     $chapter = \BookStack\Chapter::first();
     $currentBook = $chapter->book;
     $pageToCheck = $chapter->pages->first();
     $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
     $this->asAdmin()->visit($chapter->getUrl() . '/move')->see('Move Chapter')->see($chapter->name)->type('book:' . $newBook->id, 'entity_selection')->press('Move Chapter');
     $chapter = \BookStack\Chapter::find($chapter->id);
     $this->seePageIs($chapter->getUrl());
     $this->assertTrue($chapter->book->id === $newBook->id, 'Chapter Book is now the new book');
     $this->visit($newBook->getUrl())->seeInNthElement('.activity-list-item', 0, 'moved chapter')->seeInNthElement('.activity-list-item', 0, $chapter->name);
     $pageToCheck = \BookStack\Page::find($pageToCheck->id);
     $this->assertTrue($pageToCheck->book_id === $newBook->id, 'Chapter child page\'s book id has changed to the new book');
     $this->visit($pageToCheck->getUrl())->see($newBook->name);
 }