Tweaked some styles and started automated testing. Fixes #11.
Showing
23 changed files
with
254 additions
and
55 deletions
| ... | @@ -70,7 +70,7 @@ class BookController extends Controller | ... | @@ -70,7 +70,7 @@ class BookController extends Controller |
| 70 | $book->updated_by = Auth::user()->id; | 70 | $book->updated_by = Auth::user()->id; |
| 71 | $book->save(); | 71 | $book->save(); |
| 72 | Activity::add($book, 'book_create', $book->id); | 72 | Activity::add($book, 'book_create', $book->id); |
| 73 | - return redirect('/books'); | 73 | + return redirect($book->getUrl()); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | /** | 76 | /** | ... | ... |
| ... | @@ -65,7 +65,7 @@ class ChapterController extends Controller | ... | @@ -65,7 +65,7 @@ class ChapterController extends Controller |
| 65 | $chapter->updated_by = Auth::user()->id; | 65 | $chapter->updated_by = Auth::user()->id; |
| 66 | $book->chapters()->save($chapter); | 66 | $book->chapters()->save($chapter); |
| 67 | Activity::add($chapter, 'chapter_create', $book->id); | 67 | Activity::add($chapter, 'chapter_create', $book->id); |
| 68 | - return redirect($book->getUrl()); | 68 | + return redirect($chapter->getUrl()); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | /** | 71 | /** | ... | ... |
| ... | @@ -35,6 +35,11 @@ class BookRepo | ... | @@ -35,6 +35,11 @@ class BookRepo |
| 35 | return $this->book->where('slug', '=', $slug)->first(); | 35 | return $this->book->where('slug', '=', $slug)->first(); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | + /** | ||
| 39 | + * Get a new book instance from request input. | ||
| 40 | + * @param $input | ||
| 41 | + * @return Book | ||
| 42 | + */ | ||
| 38 | public function newFromInput($input) | 43 | public function newFromInput($input) |
| 39 | { | 44 | { |
| 40 | return $this->book->fill($input); | 45 | return $this->book->fill($input); | ... | ... |
| ... | @@ -64,6 +64,18 @@ return [ | ... | @@ -64,6 +64,18 @@ return [ |
| 64 | 'strict' => false, | 64 | 'strict' => false, |
| 65 | ], | 65 | ], |
| 66 | 66 | ||
| 67 | + 'mysql_testing' => [ | ||
| 68 | + 'driver' => 'mysql', | ||
| 69 | + 'host' => 'localhost', | ||
| 70 | + 'database' => 'bookstack-test', | ||
| 71 | + 'username' => 'bookstack-test', | ||
| 72 | + 'password' => 'bookstack-test', | ||
| 73 | + 'charset' => 'utf8', | ||
| 74 | + 'collation' => 'utf8_unicode_ci', | ||
| 75 | + 'prefix' => '', | ||
| 76 | + 'strict' => false, | ||
| 77 | + ], | ||
| 78 | + | ||
| 67 | 'pgsql' => [ | 79 | 'pgsql' => [ |
| 68 | 'driver' => 'pgsql', | 80 | 'driver' => 'pgsql', |
| 69 | 'host' => env('DB_HOST', 'localhost'), | 81 | 'host' => env('DB_HOST', 'localhost'), | ... | ... |
| ... | @@ -13,9 +13,30 @@ | ... | @@ -13,9 +13,30 @@ |
| 13 | 13 | ||
| 14 | $factory->define(Oxbow\User::class, function ($faker) { | 14 | $factory->define(Oxbow\User::class, function ($faker) { |
| 15 | return [ | 15 | return [ |
| 16 | - 'name' => $faker->name, | 16 | + 'name' => $faker->name, |
| 17 | - 'email' => $faker->email, | 17 | + 'email' => $faker->email, |
| 18 | - 'password' => str_random(10), | 18 | + 'password' => str_random(10), |
| 19 | 'remember_token' => str_random(10), | 19 | 'remember_token' => str_random(10), |
| 20 | ]; | 20 | ]; |
| 21 | }); | 21 | }); |
| 22 | + | ||
| 23 | +$factory->define(Oxbow\Book::class, function ($faker) { | ||
| 24 | + return [ | ||
| 25 | + 'name' => $faker->sentence, | ||
| 26 | + 'description' => $faker->paragraph | ||
| 27 | + ]; | ||
| 28 | +}); | ||
| 29 | + | ||
| 30 | +$factory->define(Oxbow\Chapter::class, function ($faker) { | ||
| 31 | + return [ | ||
| 32 | + 'name' => $faker->sentence, | ||
| 33 | + 'description' => $faker->paragraph | ||
| 34 | + ]; | ||
| 35 | +}); | ||
| 36 | + | ||
| 37 | +$factory->define(Oxbow\Page::class, function ($faker) { | ||
| 38 | + return [ | ||
| 39 | + 'name' => $faker->sentence, | ||
| 40 | + 'html' => '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>' | ||
| 41 | + ]; | ||
| 42 | +}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -24,5 +24,6 @@ | ... | @@ -24,5 +24,6 @@ |
| 24 | <env name="CACHE_DRIVER" value="array"/> | 24 | <env name="CACHE_DRIVER" value="array"/> |
| 25 | <env name="SESSION_DRIVER" value="array"/> | 25 | <env name="SESSION_DRIVER" value="array"/> |
| 26 | <env name="QUEUE_DRIVER" value="sync"/> | 26 | <env name="QUEUE_DRIVER" value="sync"/> |
| 27 | + <env name="DB_CONNECTION" value="mysql_testing"/> | ||
| 27 | </php> | 28 | </php> |
| 28 | </phpunit> | 29 | </phpunit> | ... | ... |
| ... | @@ -51,6 +51,17 @@ $button-border-radius: 2px; | ... | @@ -51,6 +51,17 @@ $button-border-radius: 2px; |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | +.text-button { | ||
| 55 | + @extend .link; | ||
| 56 | + background-color: transparent; | ||
| 57 | + padding: 0; | ||
| 58 | + margin: 0; | ||
| 59 | + border: none; | ||
| 60 | + &:focus, &:active { | ||
| 61 | + outline: 0; | ||
| 62 | + } | ||
| 63 | +} | ||
| 64 | + | ||
| 54 | .button-group { | 65 | .button-group { |
| 55 | @include clearfix; | 66 | @include clearfix; |
| 56 | .button, button[type="button"] { | 67 | .button, button[type="button"] { | ... | ... |
| ... | @@ -43,11 +43,13 @@ h1, h2, h3, h4 { | ... | @@ -43,11 +43,13 @@ h1, h2, h3, h4 { |
| 43 | /* | 43 | /* |
| 44 | * Link styling | 44 | * Link styling |
| 45 | */ | 45 | */ |
| 46 | -a { | 46 | +a, .link { |
| 47 | color: $primary; | 47 | color: $primary; |
| 48 | cursor: pointer; | 48 | cursor: pointer; |
| 49 | text-decoration: none; | 49 | text-decoration: none; |
| 50 | transition: color ease-in-out 80ms; | 50 | transition: color ease-in-out 80ms; |
| 51 | + font-family: $text; | ||
| 52 | + line-height: 1.6; | ||
| 51 | &:hover { | 53 | &:hover { |
| 52 | text-decoration: underline; | 54 | text-decoration: underline; |
| 53 | color: darken($primary, 20%); | 55 | color: darken($primary, 20%); | ... | ... |
| ... | @@ -309,8 +309,10 @@ h1, h2, h3, h4, h5, h6 { | ... | @@ -309,8 +309,10 @@ h1, h2, h3, h4, h5, h6 { |
| 309 | } | 309 | } |
| 310 | 310 | ||
| 311 | .faded { | 311 | .faded { |
| 312 | - a { | 312 | + a, button, span { |
| 313 | color: #666; | 313 | color: #666; |
| 314 | + } | ||
| 315 | + .text-button { | ||
| 314 | opacity: 0.5; | 316 | opacity: 0.5; |
| 315 | transition: all ease-in-out 120ms; | 317 | transition: all ease-in-out 120ms; |
| 316 | &:hover { | 318 | &:hover { |
| ... | @@ -324,12 +326,9 @@ h1, h2, h3, h4, h5, h6 { | ... | @@ -324,12 +326,9 @@ h1, h2, h3, h4, h5, h6 { |
| 324 | color: #000; | 326 | color: #000; |
| 325 | font-size: 0.9em; | 327 | font-size: 0.9em; |
| 326 | background-color: rgba(21, 101, 192, 0.15); | 328 | background-color: rgba(21, 101, 192, 0.15); |
| 327 | - a, span { | ||
| 328 | - color: #000; | ||
| 329 | - } | ||
| 330 | } | 329 | } |
| 331 | 330 | ||
| 332 | -.breadcrumbs a, .action-buttons a { | 331 | +.breadcrumbs .text-button, .action-buttons .text-button { |
| 333 | display: inline-block; | 332 | display: inline-block; |
| 334 | padding: $-s; | 333 | padding: $-s; |
| 335 | &:last-child { | 334 | &:last-child { |
| ... | @@ -340,7 +339,7 @@ h1, h2, h3, h4, h5, h6 { | ... | @@ -340,7 +339,7 @@ h1, h2, h3, h4, h5, h6 { |
| 340 | text-align: right; | 339 | text-align: right; |
| 341 | &.text-left { | 340 | &.text-left { |
| 342 | text-align: left; | 341 | text-align: left; |
| 343 | - a { | 342 | + .text-button { |
| 344 | padding-right: $-m; | 343 | padding-right: $-m; |
| 345 | padding-left: 0; | 344 | padding-left: 0; |
| 346 | } | 345 | } | ... | ... |
| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | <div class="col-md-6 faded"> | 9 | <div class="col-md-6 faded"> |
| 10 | <div class="action-buttons"> | 10 | <div class="action-buttons"> |
| 11 | @if($currentUser->can('book-create')) | 11 | @if($currentUser->can('book-create')) |
| 12 | - <a href="/books/create" class="text-pos"><i class="zmdi zmdi-plus"></i>Add new book</a> | 12 | + <a href="/books/create" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>Add new book</a> |
| 13 | @endif | 13 | @endif |
| 14 | </div> | 14 | </div> |
| 15 | </div> | 15 | </div> | ... | ... |
| ... | @@ -8,17 +8,17 @@ | ... | @@ -8,17 +8,17 @@ |
| 8 | <div class="col-md-12"> | 8 | <div class="col-md-12"> |
| 9 | <div class="action-buttons faded"> | 9 | <div class="action-buttons faded"> |
| 10 | @if($currentUser->can('page-create')) | 10 | @if($currentUser->can('page-create')) |
| 11 | - <a href="{{$book->getUrl() . '/page/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Page</a> | 11 | + <a href="{{$book->getUrl() . '/page/create'}}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i> New Page</a> |
| 12 | @endif | 12 | @endif |
| 13 | @if($currentUser->can('chapter-create')) | 13 | @if($currentUser->can('chapter-create')) |
| 14 | - <a href="{{$book->getUrl() . '/chapter/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Chapter</a> | 14 | + <a href="{{$book->getUrl() . '/chapter/create'}}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i> New Chapter</a> |
| 15 | @endif | 15 | @endif |
| 16 | @if($currentUser->can('book-update')) | 16 | @if($currentUser->can('book-update')) |
| 17 | - <a href="{{$book->getEditUrl()}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a> | 17 | + <a href="{{$book->getEditUrl()}}" class="text-primary text-button"><i class="zmdi zmdi-edit"></i>Edit</a> |
| 18 | - <a href="{{ $book->getUrl() }}/sort" class="text-primary"><i class="zmdi zmdi-sort"></i>Sort</a> | 18 | + <a href="{{ $book->getUrl() }}/sort" class="text-primary text-button"><i class="zmdi zmdi-sort"></i>Sort</a> |
| 19 | @endif | 19 | @endif |
| 20 | @if($currentUser->can('book-delete')) | 20 | @if($currentUser->can('book-delete')) |
| 21 | - <a href="{{ $book->getUrl() }}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | 21 | + <a href="{{ $book->getUrl() }}/delete" class="text-neg text-button"><i class="zmdi zmdi-delete"></i>Delete</a> |
| 22 | @endif | 22 | @endif |
| 23 | </div> | 23 | </div> |
| 24 | </div> | 24 | </div> | ... | ... |
| ... | @@ -13,5 +13,5 @@ | ... | @@ -13,5 +13,5 @@ |
| 13 | 13 | ||
| 14 | <div class="form-group"> | 14 | <div class="form-group"> |
| 15 | <a href="{{ back()->getTargetUrl() }}" class="button muted">Cancel</a> | 15 | <a href="{{ back()->getTargetUrl() }}" class="button muted">Cancel</a> |
| 16 | - <button type="submit" class="button pos">Save</button> | 16 | + <button type="submit" class="button pos">Save Chapter</button> |
| 17 | </div> | 17 | </div> | ... | ... |
| ... | @@ -7,19 +7,19 @@ | ... | @@ -7,19 +7,19 @@ |
| 7 | <div class="row"> | 7 | <div class="row"> |
| 8 | <div class="col-md-4 faded"> | 8 | <div class="col-md-4 faded"> |
| 9 | <div class="breadcrumbs"> | 9 | <div class="breadcrumbs"> |
| 10 | - <a href="{{$book->getUrl()}}" class="text-book"><i class="zmdi zmdi-book"></i>{{ $book->name }}</a> | 10 | + <a href="{{$book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $book->name }}</a> |
| 11 | </div> | 11 | </div> |
| 12 | </div> | 12 | </div> |
| 13 | <div class="col-md-8 faded"> | 13 | <div class="col-md-8 faded"> |
| 14 | <div class="action-buttons"> | 14 | <div class="action-buttons"> |
| 15 | @if($currentUser->can('chapter-create')) | 15 | @if($currentUser->can('chapter-create')) |
| 16 | - <a href="{{$chapter->getUrl() . '/create-page'}}" class="text-pos"><i class="zmdi zmdi-plus"></i>New Page</a> | 16 | + <a href="{{$chapter->getUrl() . '/create-page'}}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>New Page</a> |
| 17 | @endif | 17 | @endif |
| 18 | @if($currentUser->can('chapter-update')) | 18 | @if($currentUser->can('chapter-update')) |
| 19 | - <a href="{{$chapter->getUrl() . '/edit'}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a> | 19 | + <a href="{{$chapter->getUrl() . '/edit'}}" class="text-primary text-button"><i class="zmdi zmdi-edit"></i>Edit</a> |
| 20 | @endif | 20 | @endif |
| 21 | @if($currentUser->can('chapter-delete')) | 21 | @if($currentUser->can('chapter-delete')) |
| 22 | - <a href="{{$chapter->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | 22 | + <a href="{{$chapter->getUrl() . '/delete'}}" class="text-neg text-button"><i class="zmdi zmdi-delete"></i>Delete</a> |
| 23 | @endif | 23 | @endif |
| 24 | </div> | 24 | </div> |
| 25 | </div> | 25 | </div> | ... | ... |
| ... | @@ -9,13 +9,13 @@ | ... | @@ -9,13 +9,13 @@ |
| 9 | <div class="row"> | 9 | <div class="row"> |
| 10 | <div class="col-md-4 faded"> | 10 | <div class="col-md-4 faded"> |
| 11 | <div class="action-buttons text-left"> | 11 | <div class="action-buttons text-left"> |
| 12 | - <a onclick="$('body>header').slideToggle();" class="text-primary"><i class="zmdi zmdi-swap-vertical"></i>Toggle Header</a> | 12 | + <a onclick="$('body>header').slideToggle();" class="text-button text-primary"><i class="zmdi zmdi-swap-vertical"></i>Toggle Header</a> |
| 13 | </div> | 13 | </div> |
| 14 | </div> | 14 | </div> |
| 15 | <div class="col-md-8 faded"> | 15 | <div class="col-md-8 faded"> |
| 16 | <div class="action-buttons"> | 16 | <div class="action-buttons"> |
| 17 | - <a href="{{ back()->getTargetUrl() }}" class="text-primary"><i class="zmdi zmdi-close"></i>Cancel</a> | 17 | + <a href="{{ back()->getTargetUrl() }}" class="text-button text-primary"><i class="zmdi zmdi-close"></i>Cancel</a> |
| 18 | - <a onclick="$(this).submitForm();" type="submit" class="text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</a> | 18 | + <button type="submit" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> |
| 19 | </div> | 19 | </div> |
| 20 | </div> | 20 | </div> |
| 21 | </div> | 21 | </div> | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <div class="row"> | 7 | <div class="row"> |
| 8 | <div class="col-md-6 faded"> | 8 | <div class="col-md-6 faded"> |
| 9 | <div class="breadcrumbs"> | 9 | <div class="breadcrumbs"> |
| 10 | - <a href="{{$page->getUrl()}}" class="text-primary"><i class="zmdi zmdi-arrow-left"></i>Back to page</a> | 10 | + <a href="{{$page->getUrl()}}" class="text-primary text-button"><i class="zmdi zmdi-arrow-left"></i>Back to page</a> |
| 11 | </div> | 11 | </div> |
| 12 | </div> | 12 | </div> |
| 13 | <div class="col-md-6 faded"> | 13 | <div class="col-md-6 faded"> | ... | ... |
| ... | @@ -7,10 +7,10 @@ | ... | @@ -7,10 +7,10 @@ |
| 7 | <div class="row"> | 7 | <div class="row"> |
| 8 | <div class="col-md-6 faded"> | 8 | <div class="col-md-6 faded"> |
| 9 | <div class="breadcrumbs"> | 9 | <div class="breadcrumbs"> |
| 10 | - <a href="{{$book->getUrl()}}" class="text-book"><i class="zmdi zmdi-book"></i>{{ $book->name }}</a> | 10 | + <a href="{{$book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $book->name }}</a> |
| 11 | @if($page->hasChapter()) | 11 | @if($page->hasChapter()) |
| 12 | <span class="sep">»</span> | 12 | <span class="sep">»</span> |
| 13 | - <a href="{{ $page->chapter->getUrl() }}" class="text-chapter"> | 13 | + <a href="{{ $page->chapter->getUrl() }}" class="text-chapter text-button"> |
| 14 | <i class="zmdi zmdi-collection-bookmark"></i> | 14 | <i class="zmdi zmdi-collection-bookmark"></i> |
| 15 | {{$page->chapter->name}} | 15 | {{$page->chapter->name}} |
| 16 | </a> | 16 | </a> |
| ... | @@ -20,11 +20,11 @@ | ... | @@ -20,11 +20,11 @@ |
| 20 | <div class="col-md-6 faded"> | 20 | <div class="col-md-6 faded"> |
| 21 | <div class="action-buttons"> | 21 | <div class="action-buttons"> |
| 22 | @if($currentUser->can('page-update')) | 22 | @if($currentUser->can('page-update')) |
| 23 | - <a href="{{$page->getUrl() . '/revisions'}}" class="text-primary"><i class="zmdi zmdi-replay"></i>Revisions</a> | 23 | + <a href="{{$page->getUrl() . '/revisions'}}" class="text-primary text-button"><i class="zmdi zmdi-replay"></i>Revisions</a> |
| 24 | - <a href="{{$page->getUrl() . '/edit'}}" class="text-primary" ><i class="zmdi zmdi-edit"></i>Edit</a> | 24 | + <a href="{{$page->getUrl() . '/edit'}}" class="text-primary text-button" ><i class="zmdi zmdi-edit"></i>Edit</a> |
| 25 | @endif | 25 | @endif |
| 26 | @if($currentUser->can('page-delete')) | 26 | @if($currentUser->can('page-delete')) |
| 27 | - <a href="{{$page->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | 27 | + <a href="{{$page->getUrl() . '/delete'}}" class="text-neg text-button"><i class="zmdi zmdi-delete"></i>Delete</a> |
| 28 | @endif | 28 | @endif |
| 29 | </div> | 29 | </div> |
| 30 | </div> | 30 | </div> | ... | ... |
| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | @foreach($book->children() as $bookChild) | 6 | @foreach($book->children() as $bookChild) |
| 7 | <li class="list-item-{{ $bookChild->getName() }}"> | 7 | <li class="list-item-{{ $bookChild->getName() }}"> |
| 8 | <a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getName() }} {{ $current->matches($bookChild)? 'selected' : '' }}"> | 8 | <a href="{{$bookChild->getUrl()}}" class="{{ $bookChild->getName() }} {{ $current->matches($bookChild)? 'selected' : '' }}"> |
| 9 | - @if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark chapter-toggle"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }} | 9 | + @if($bookChild->isA('chapter'))<i class="zmdi zmdi-collection-bookmark"></i>@else <i class="zmdi zmdi-file-text"></i>@endif{{ $bookChild->name }} |
| 10 | </a> | 10 | </a> |
| 11 | 11 | ||
| 12 | @if($bookChild->isA('chapter') && count($bookChild->pages) > 0) | 12 | @if($bookChild->isA('chapter') && count($bookChild->pages) > 0) | ... | ... |
| ... | @@ -3,8 +3,8 @@ | ... | @@ -3,8 +3,8 @@ |
| 3 | <div class="container"> | 3 | <div class="container"> |
| 4 | <div class="row"> | 4 | <div class="row"> |
| 5 | <div class="col-md-12 setting-nav"> | 5 | <div class="col-md-12 setting-nav"> |
| 6 | - <a href="/settings" @if($selected == 'settings') class="selected" @endif><i class="zmdi zmdi-settings"></i>Settings</a> | 6 | + <a href="/settings" @if($selected == 'settings') class="selected text-button" @endif><i class="zmdi zmdi-settings"></i>Settings</a> |
| 7 | - <a href="/users" @if($selected == 'users') class="selected" @endif><i class="zmdi zmdi-accounts"></i>Users</a> | 7 | + <a href="/users" @if($selected == 'users') class="selected text-button" @endif><i class="zmdi zmdi-accounts"></i>Users</a> |
| 8 | </div> | 8 | </div> |
| 9 | </div> | 9 | </div> |
| 10 | </div> | 10 | </div> | ... | ... |
| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | <div class="col-md-6"></div> | 9 | <div class="col-md-6"></div> |
| 10 | <div class="col-md-6 faded"> | 10 | <div class="col-md-6 faded"> |
| 11 | <div class="action-buttons"> | 11 | <div class="action-buttons"> |
| 12 | - <a href="/users/{{$user->id}}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete User</a> | 12 | + <a href="/users/{{$user->id}}/delete" class="text-neg text-button"><i class="zmdi zmdi-delete"></i>Delete User</a> |
| 13 | </div> | 13 | </div> |
| 14 | </div> | 14 | </div> |
| 15 | </div> | 15 | </div> | ... | ... |
tests/AuthTest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +class AuthTest extends TestCase | ||
| 4 | +{ | ||
| 5 | + | ||
| 6 | + public function testAuthWorking() | ||
| 7 | + { | ||
| 8 | + $this->visit('/') | ||
| 9 | + ->seePageIs('/login'); | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + public function testLogin() | ||
| 13 | + { | ||
| 14 | + $this->visit('/') | ||
| 15 | + ->seePageIs('/login') | ||
| 16 | + ->type('admin@admin.com', '#email') | ||
| 17 | + ->type('password', '#password') | ||
| 18 | + ->press('Sign In') | ||
| 19 | + ->seePageIs('/') | ||
| 20 | + ->see('BookStack'); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public function testLogout() | ||
| 24 | + { | ||
| 25 | + $this->asAdmin() | ||
| 26 | + ->visit('/') | ||
| 27 | + ->seePageIs('/') | ||
| 28 | + ->visit('/logout') | ||
| 29 | + ->visit('/') | ||
| 30 | + ->seePageIs('/login'); | ||
| 31 | + } | ||
| 32 | +} |
tests/EntityTest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +class EntityTest extends TestCase | ||
| 4 | +{ | ||
| 5 | + | ||
| 6 | + public function testEntityCreation() | ||
| 7 | + { | ||
| 8 | + | ||
| 9 | + // Test Creation | ||
| 10 | + $book = $this->bookCreation(); | ||
| 11 | + $chapter = $this->chapterCreation($book); | ||
| 12 | + $page = $this->pageCreation($chapter); | ||
| 13 | + | ||
| 14 | + // Test Updating | ||
| 15 | + $book = $this->bookUpdate($book); | ||
| 16 | + | ||
| 17 | + // Test Deletion | ||
| 18 | + $this->bookDelete($book); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public function bookDelete(\Oxbow\Book $book) | ||
| 22 | + { | ||
| 23 | + $this->asAdmin() | ||
| 24 | + ->visit($book->getUrl()) | ||
| 25 | + // Check link works correctly | ||
| 26 | + ->click('Delete') | ||
| 27 | + ->seePageIs($book->getUrl() . '/delete') | ||
| 28 | + // Ensure the book name is show to user | ||
| 29 | + ->see($book->name) | ||
| 30 | + ->press('Confirm') | ||
| 31 | + ->seePageIs('/books') | ||
| 32 | + ->notSeeInDatabase('books', ['id' => $book->id]); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public function bookUpdate(\Oxbow\Book $book) | ||
| 36 | + { | ||
| 37 | + $newName = $book->name . ' Updated'; | ||
| 38 | + $this->asAdmin() | ||
| 39 | + // Go to edit screen | ||
| 40 | + ->visit($book->getUrl() . '/edit') | ||
| 41 | + ->see($book->name) | ||
| 42 | + // Submit new name | ||
| 43 | + ->type($newName, '#name') | ||
| 44 | + ->press('Save Book') | ||
| 45 | + // Check page url and text | ||
| 46 | + ->seePageIs($book->getUrl() . '-updated') | ||
| 47 | + ->see($newName); | ||
| 48 | + | ||
| 49 | + return \Oxbow\Book::find($book->id); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public function pageCreation($chapter) | ||
| 53 | + { | ||
| 54 | + $page = factory(\Oxbow\Page::class)->make([ | ||
| 55 | + 'name' => 'My First Page' | ||
| 56 | + ]); | ||
| 57 | + | ||
| 58 | + $this->asAdmin() | ||
| 59 | + // Navigate to page create form | ||
| 60 | + ->visit($chapter->getUrl()) | ||
| 61 | + ->click('New Page') | ||
| 62 | + ->seePageIs($chapter->getUrl() . '/create-page') | ||
| 63 | + // Fill out form | ||
| 64 | + ->type($page->name, '#name') | ||
| 65 | + ->type($page->html, '#html') | ||
| 66 | + ->press('Save Page') | ||
| 67 | + // Check redirect and page | ||
| 68 | + ->seePageIs($chapter->book->getUrl() . '/page/my-first-page') | ||
| 69 | + ->see($page->name); | ||
| 70 | + | ||
| 71 | + $page = \Oxbow\Page::where('slug', '=', 'my-first-page')->where('chapter_id', '=', $chapter->id)->first(); | ||
| 72 | + return $page; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public function chapterCreation(\Oxbow\Book $book) | ||
| 76 | + { | ||
| 77 | + $chapter = factory(\Oxbow\Chapter::class)->make([ | ||
| 78 | + 'name' => 'My First Chapter' | ||
| 79 | + ]); | ||
| 80 | + | ||
| 81 | + $this->asAdmin() | ||
| 82 | + // Navigate to chapter create page | ||
| 83 | + ->visit($book->getUrl()) | ||
| 84 | + ->click('New Chapter') | ||
| 85 | + ->seePageIs($book->getUrl() . '/chapter/create') | ||
| 86 | + // Fill out form | ||
| 87 | + ->type($chapter->name, '#name') | ||
| 88 | + ->type($chapter->description, '#description') | ||
| 89 | + ->press('Save Chapter') | ||
| 90 | + // Check redirect and landing page | ||
| 91 | + ->seePageIs($book->getUrl() . '/chapter/my-first-chapter') | ||
| 92 | + ->see($chapter->name)->see($chapter->description); | ||
| 93 | + | ||
| 94 | + $chapter = \Oxbow\Chapter::where('slug', '=', 'my-first-chapter')->where('book_id', '=', $book->id)->first(); | ||
| 95 | + return $chapter; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public function bookCreation() | ||
| 99 | + { | ||
| 100 | + $book = factory(\Oxbow\Book::class)->make([ | ||
| 101 | + 'name' => 'My First Book' | ||
| 102 | + ]); | ||
| 103 | + $this->asAdmin() | ||
| 104 | + ->visit('/books') | ||
| 105 | + // Choose to create a book | ||
| 106 | + ->click('Add new book') | ||
| 107 | + ->seePageIs('/books/create') | ||
| 108 | + // Fill out form & save | ||
| 109 | + ->type($book->name, '#name') | ||
| 110 | + ->type($book->description, '#description') | ||
| 111 | + ->press('Save Book') | ||
| 112 | + // Check it redirects correctly | ||
| 113 | + ->seePageIs('/books/my-first-book') | ||
| 114 | + ->see($book->name)->see($book->description); | ||
| 115 | + | ||
| 116 | + $book = \Oxbow\Book::where('slug', '=', 'my-first-book')->first(); | ||
| 117 | + return $book; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + | ||
| 121 | +} |
tests/ExampleTest.php
deleted
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -use Illuminate\Foundation\Testing\WithoutMiddleware; | ||
| 4 | -use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
| 5 | -use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
| 6 | - | ||
| 7 | -class ExampleTest extends TestCase | ||
| 8 | -{ | ||
| 9 | - /** | ||
| 10 | - * A basic functional test example. | ||
| 11 | - * | ||
| 12 | - * @return void | ||
| 13 | - */ | ||
| 14 | - public function testBasicExample() | ||
| 15 | - { | ||
| 16 | - $this->visit('/') | ||
| 17 | - ->see('Laravel 5'); | ||
| 18 | - } | ||
| 19 | -} |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | +use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
| 4 | + | ||
| 3 | class TestCase extends Illuminate\Foundation\Testing\TestCase | 5 | class TestCase extends Illuminate\Foundation\Testing\TestCase |
| 4 | { | 6 | { |
| 7 | + | ||
| 8 | + use DatabaseTransactions; | ||
| 9 | + | ||
| 5 | /** | 10 | /** |
| 6 | * The base URL to use while testing the application. | 11 | * The base URL to use while testing the application. |
| 7 | * | 12 | * |
| 8 | * @var string | 13 | * @var string |
| 9 | */ | 14 | */ |
| 10 | protected $baseUrl = 'http://localhost'; | 15 | protected $baseUrl = 'http://localhost'; |
| 16 | + private $admin; | ||
| 11 | 17 | ||
| 12 | /** | 18 | /** |
| 13 | * Creates the application. | 19 | * Creates the application. |
| ... | @@ -22,4 +28,12 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase | ... | @@ -22,4 +28,12 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase |
| 22 | 28 | ||
| 23 | return $app; | 29 | return $app; |
| 24 | } | 30 | } |
| 31 | + | ||
| 32 | + public function asAdmin() | ||
| 33 | + { | ||
| 34 | + if($this->admin === null) { | ||
| 35 | + $this->admin = \Oxbow\User::find(1); | ||
| 36 | + } | ||
| 37 | + return $this->actingAs($this->admin); | ||
| 38 | + } | ||
| 25 | } | 39 | } | ... | ... |
-
Please register or sign in to post a comment