mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Re-structured the app code to be feature based rather than code type based
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
|
||||
use BookStack\Entities\Book;
|
||||
|
||||
class ActivityTrackingTest extends BrowserKitTest
|
||||
{
|
||||
|
||||
public function test_recently_viewed_books()
|
||||
{
|
||||
$books = \BookStack\Book::all()->take(10);
|
||||
$books = Book::all()->take(10);
|
||||
|
||||
$this->asAdmin()->visit('/books')
|
||||
->dontSeeInElement('#recents', $books[0]->name)
|
||||
@ -20,7 +22,7 @@ class ActivityTrackingTest extends BrowserKitTest
|
||||
|
||||
public function test_popular_books()
|
||||
{
|
||||
$books = \BookStack\Book::all()->take(10);
|
||||
$books = Book::all()->take(10);
|
||||
|
||||
$this->asAdmin()->visit('/books')
|
||||
->dontSeeInElement('#popular', $books[0]->name)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Attachment;
|
||||
use BookStack\Page;
|
||||
use BookStack\Services\PermissionService;
|
||||
use BookStack\Uploads\Attachment;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
|
||||
class AttachmentTest extends TestCase
|
||||
{
|
||||
@ -44,8 +44,8 @@ class AttachmentTest extends TestCase
|
||||
*/
|
||||
protected function deleteUploads()
|
||||
{
|
||||
$fileService = $this->app->make(\BookStack\Services\AttachmentService::class);
|
||||
foreach (\BookStack\Attachment::all() as $file) {
|
||||
$fileService = $this->app->make(\BookStack\Uploads\AttachmentService::class);
|
||||
foreach (\BookStack\Uploads\Attachment::all() as $file) {
|
||||
$fileService->deleteFile($file);
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ class AttachmentTest extends TestCase
|
||||
'uploaded_to' => $page->id,
|
||||
]);
|
||||
|
||||
$attachmentId = \BookStack\Attachment::first()->id;
|
||||
$attachmentId = \BookStack\Uploads\Attachment::first()->id;
|
||||
|
||||
$update = $this->call('PUT', 'attachments/' . $attachmentId, [
|
||||
'uploaded_to' => $page->id,
|
||||
@ -175,7 +175,7 @@ class AttachmentTest extends TestCase
|
||||
$filePath = base_path('storage/' . $this->getUploadPath($fileName));
|
||||
$this->assertTrue(file_exists($filePath), 'File at path ' . $filePath . ' does not exist');
|
||||
|
||||
$attachment = \BookStack\Attachment::first();
|
||||
$attachment = \BookStack\Uploads\Attachment::first();
|
||||
$this->delete($attachment->getUrl());
|
||||
|
||||
$this->assertDatabaseMissing('attachments', [
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Notifications\ConfirmEmail;
|
||||
use BookStack\User;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Settings\SettingService;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class AuthTest extends BrowserKitTest
|
||||
@ -21,7 +22,7 @@ class AuthTest extends BrowserKitTest
|
||||
|
||||
public function test_public_viewing()
|
||||
{
|
||||
$settings = app('BookStack\Services\SettingService');
|
||||
$settings = app(SettingService::class);
|
||||
$settings->put('app-public', 'true');
|
||||
$this->visit('/')
|
||||
->seePageIs('/')
|
||||
@ -248,7 +249,7 @@ class AuthTest extends BrowserKitTest
|
||||
|
||||
public function test_user_cannot_be_deleted_if_last_admin()
|
||||
{
|
||||
$adminRole = \BookStack\Role::getRole('admin');
|
||||
$adminRole = \BookStack\Auth\Role::getRole('admin');
|
||||
// Ensure we currently only have 1 admin user
|
||||
$this->assertEquals(1, $adminRole->users()->count());
|
||||
$user = $adminRole->users->first();
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
use BookStack\Role;
|
||||
use BookStack\Services\Ldap;
|
||||
use BookStack\User;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\Access\Ldap;
|
||||
use BookStack\Auth\User;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class LdapTest extends BrowserKitTest
|
||||
|
@ -6,7 +6,7 @@ class SocialAuthTest extends TestCase
|
||||
public function test_social_registration()
|
||||
{
|
||||
// http://docs.mockery.io/en/latest/reference/startup_methods.html
|
||||
$user = factory(\BookStack\User::class)->make();
|
||||
$user = factory(\BookStack\Auth\User::class)->make();
|
||||
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
config(['GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
|
||||
@ -86,7 +86,7 @@ class SocialAuthTest extends TestCase
|
||||
'APP_URL' => 'http://localhost'
|
||||
]);
|
||||
|
||||
$user = factory(\BookStack\User::class)->make();
|
||||
$user = factory(\BookStack\Auth\User::class)->make();
|
||||
$mockSocialite = \Mockery::mock('Laravel\Socialite\Contracts\Factory');
|
||||
$this->app['Laravel\Socialite\Contracts\Factory'] = $mockSocialite;
|
||||
$mockSocialDriver = \Mockery::mock('Laravel\Socialite\Contracts\Provider');
|
||||
@ -125,7 +125,7 @@ class SocialAuthTest extends TestCase
|
||||
'APP_URL' => 'http://localhost', 'services.google.auto_register' => true, 'services.google.auto_confirm' => true
|
||||
]);
|
||||
|
||||
$user = factory(\BookStack\User::class)->make();
|
||||
$user = factory(\BookStack\Auth\User::class)->make();
|
||||
$mockSocialite = \Mockery::mock('Laravel\Socialite\Contracts\Factory');
|
||||
$this->app['Laravel\Socialite\Contracts\Factory'] = $mockSocialite;
|
||||
$mockSocialDriver = \Mockery::mock('Laravel\Socialite\Contracts\Provider');
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Entity;
|
||||
use BookStack\Role;
|
||||
use BookStack\Services\PermissionService;
|
||||
use BookStack\Entities\Entity;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Settings\SettingService;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Laravel\BrowserKitTesting\TestCase;
|
||||
@ -46,7 +47,7 @@ abstract class BrowserKitTest extends TestCase
|
||||
*/
|
||||
public function getNormalUser()
|
||||
{
|
||||
return \BookStack\User::where('system_name', '=', null)->get()->last();
|
||||
return \BookStack\Auth\User::where('system_name', '=', null)->get()->last();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +56,7 @@ abstract class BrowserKitTest extends TestCase
|
||||
*/
|
||||
protected function setSettings($settingsArray)
|
||||
{
|
||||
$settings = app('BookStack\Services\SettingService');
|
||||
$settings = app(SettingService::class);
|
||||
foreach ($settingsArray as $key => $value) {
|
||||
$settings->put($key, $value);
|
||||
}
|
||||
@ -70,9 +71,9 @@ abstract class BrowserKitTest extends TestCase
|
||||
protected function createEntityChainBelongingToUser($creatorUser, $updaterUser = false)
|
||||
{
|
||||
if ($updaterUser === false) $updaterUser = $creatorUser;
|
||||
$book = factory(\BookStack\Book::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]);
|
||||
$chapter = factory(\BookStack\Chapter::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]);
|
||||
$page = factory(\BookStack\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id, 'chapter_id' => $chapter->id]);
|
||||
$book = factory(\BookStack\Entities\Book::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id]);
|
||||
$chapter = factory(\BookStack\Entities\Chapter::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id]);
|
||||
$page = factory(\BookStack\Entities\Page::class)->create(['created_by' => $creatorUser->id, 'updated_by' => $updaterUser->id, 'book_id' => $book->id, 'chapter_id' => $chapter->id]);
|
||||
$restrictionService = $this->app[PermissionService::class];
|
||||
$restrictionService->buildJointPermissionsForEntity($book);
|
||||
return [
|
||||
@ -100,7 +101,7 @@ abstract class BrowserKitTest extends TestCase
|
||||
*/
|
||||
protected function getNewBlankUser($attributes = [])
|
||||
{
|
||||
$user = factory(\BookStack\User::class)->create($attributes);
|
||||
$user = factory(\BookStack\Auth\User::class)->create($attributes);
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\JointPermission;
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\User;
|
||||
use BookStack\Auth\Permissions\JointPermission;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
use BookStack\Auth\User;
|
||||
|
||||
class CommandsTest extends TestCase
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Book;
|
||||
use BookStack\Bookshelf;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
|
||||
class BookShelfTest extends TestCase
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ class CommentSettingTest extends BrowserKitTest {
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->page = \BookStack\Page::first();
|
||||
$this->page = \BookStack\Entities\Page::first();
|
||||
}
|
||||
|
||||
public function test_comment_disable () {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Page;
|
||||
use BookStack\Comment;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Actions\Comment;
|
||||
|
||||
class CommentTest extends TestCase
|
||||
{
|
||||
@ -23,7 +23,7 @@ class CommentTest extends TestCase
|
||||
$this->assertDatabaseHas('comments', [
|
||||
'local_id' => 1,
|
||||
'entity_id' => $page->id,
|
||||
'entity_type' => 'BookStack\\Page',
|
||||
'entity_type' => Page::newModelInstance()->getMorphClass(),
|
||||
'text' => $comment->text,
|
||||
'parent_id' => 2
|
||||
]);
|
||||
|
@ -1,16 +1,16 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
|
||||
use BookStack\Bookshelf;
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Page;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
|
||||
class EntitySearchTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_page_search()
|
||||
{
|
||||
$book = \BookStack\Book::all()->first();
|
||||
$book = \BookStack\Entities\Book::all()->first();
|
||||
$page = $book->pages->first();
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=' . urlencode($page->name));
|
||||
@ -54,7 +54,7 @@ class EntitySearchTest extends TestCase
|
||||
|
||||
public function test_book_search()
|
||||
{
|
||||
$book = \BookStack\Book::first();
|
||||
$book = \BookStack\Entities\Book::first();
|
||||
$page = $book->pages->last();
|
||||
$chapter = $book->chapters->last();
|
||||
|
||||
@ -67,7 +67,7 @@ class EntitySearchTest extends TestCase
|
||||
|
||||
public function test_chapter_search()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::has('pages')->first();
|
||||
$chapter = \BookStack\Entities\Chapter::has('pages')->first();
|
||||
$page = $chapter->pages[0];
|
||||
|
||||
$pageTestResp = $this->asEditor()->get('/search/chapter/' . $chapter->id . '?term=' . urlencode($page->name));
|
||||
@ -77,11 +77,11 @@ class EntitySearchTest extends TestCase
|
||||
public function test_tag_search()
|
||||
{
|
||||
$newTags = [
|
||||
new \BookStack\Tag([
|
||||
new \BookStack\Actions\Tag([
|
||||
'name' => 'animal',
|
||||
'value' => 'cat'
|
||||
]),
|
||||
new \BookStack\Tag([
|
||||
new \BookStack\Actions\Tag([
|
||||
'name' => 'color',
|
||||
'value' => 'red'
|
||||
])
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Book;
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Repos\UserRepo;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
use BookStack\Auth\UserRepo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class EntityTest extends BrowserKitTest
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Page;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
|
||||
class ExportTest extends TestCase
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ class MarkdownTest extends BrowserKitTest
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->page = \BookStack\Page::first();
|
||||
$this->page = \BookStack\Entities\Page::first();
|
||||
}
|
||||
|
||||
protected function setMarkdownEditor()
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
|
||||
class PageContentTest extends TestCase
|
||||
{
|
||||
|
@ -9,8 +9,8 @@ class PageDraftTest extends BrowserKitTest
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->page = \BookStack\Page::first();
|
||||
$this->entityRepo = app('\BookStack\Repos\EntityRepo');
|
||||
$this->page = \BookStack\Entities\Page::first();
|
||||
$this->entityRepo = app('\BookStack\Entities\EntityRepo');
|
||||
}
|
||||
|
||||
public function test_draft_content_shows_if_available()
|
||||
@ -48,7 +48,7 @@ class PageDraftTest extends BrowserKitTest
|
||||
|
||||
public function test_alert_message_shows_if_someone_else_editing()
|
||||
{
|
||||
$nonEditedPage = \BookStack\Page::take(10)->get()->last();
|
||||
$nonEditedPage = \BookStack\Entities\Page::take(10)->get()->last();
|
||||
$addedContent = '<p>test message content</p>';
|
||||
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
|
||||
->dontSeeInField('html', $addedContent);
|
||||
@ -67,7 +67,7 @@ class PageDraftTest extends BrowserKitTest
|
||||
|
||||
public function test_draft_pages_show_on_homepage()
|
||||
{
|
||||
$book = \BookStack\Book::first();
|
||||
$book = \BookStack\Entities\Book::first();
|
||||
$this->asAdmin()->visit('/')
|
||||
->dontSeeInElement('#recent-drafts', 'New Page')
|
||||
->visit($book->getUrl() . '/create-page')
|
||||
@ -77,7 +77,7 @@ class PageDraftTest extends BrowserKitTest
|
||||
|
||||
public function test_draft_pages_not_visible_by_others()
|
||||
{
|
||||
$book = \BookStack\Book::first();
|
||||
$book = \BookStack\Entities\Book::first();
|
||||
$chapter = $book->chapters->first();
|
||||
$newUser = $this->getEditor();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Entity;
|
||||
|
||||
|
||||
use BookStack\Page;
|
||||
use BookStack\Entities\Page;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PageRevisionTest extends TestCase
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Book;
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
|
||||
class SortTest extends TestCase
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Book;
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Tag;
|
||||
use BookStack\Page;
|
||||
use BookStack\Services\PermissionService;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Actions\Tag;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
|
||||
class TagTest extends BrowserKitTest
|
||||
{
|
||||
@ -13,7 +13,7 @@ class TagTest extends BrowserKitTest
|
||||
|
||||
/**
|
||||
* Get an instance of a page that has many tags.
|
||||
* @param Tag[]|bool $tags
|
||||
* @param \BookStack\Actions\Tag[]|bool $tags
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getEntityWithTags($class, $tags = false)
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Image;
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Services\ImageService;
|
||||
use BookStack\Uploads\Image;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
use BookStack\Uploads\ImageService;
|
||||
|
||||
class ImageTest extends TestCase
|
||||
{
|
||||
|
@ -1,16 +1,18 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Book;
|
||||
use BookStack\Bookshelf;
|
||||
use BookStack\Entity;
|
||||
use BookStack\User;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Entity;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
use BookStack\Entities\Page;
|
||||
|
||||
class RestrictionsTest extends BrowserKitTest
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User
|
||||
* @var \BookStack\Auth\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
@ -223,7 +225,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_view_restriction()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$chapterPage = $chapter->pages->first();
|
||||
|
||||
$chapterUrl = $chapter->getUrl();
|
||||
@ -248,7 +250,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_create_restriction()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
|
||||
$chapterUrl = $chapter->getUrl();
|
||||
$this->actingAs($this->user)
|
||||
@ -275,7 +277,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_update_restriction()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$chapterPage = $chapter->pages->first();
|
||||
|
||||
$chapterUrl = $chapter->getUrl();
|
||||
@ -300,7 +302,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_delete_restriction()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$chapterPage = $chapter->pages->first();
|
||||
|
||||
$chapterUrl = $chapter->getUrl();
|
||||
@ -325,7 +327,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_page_view_restriction()
|
||||
{
|
||||
$page = \BookStack\Page::first();
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
|
||||
$pageUrl = $page->getUrl();
|
||||
$this->actingAs($this->user)
|
||||
@ -345,7 +347,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_page_update_restriction()
|
||||
{
|
||||
$page = \BookStack\Chapter::first();
|
||||
$page = Chapter::first();
|
||||
|
||||
$pageUrl = $page->getUrl();
|
||||
$this->actingAs($this->user)
|
||||
@ -365,7 +367,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_page_delete_restriction()
|
||||
{
|
||||
$page = \BookStack\Page::first();
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
|
||||
$pageUrl = $page->getUrl();
|
||||
$this->actingAs($this->user)
|
||||
@ -394,7 +396,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
->seeInDatabase('bookshelves', ['id' => $shelf->id, 'restricted' => true])
|
||||
->seeInDatabase('entity_permissions', [
|
||||
'restrictable_id' => $shelf->id,
|
||||
'restrictable_type' => 'BookStack\Bookshelf',
|
||||
'restrictable_type' => Bookshelf::newModelInstance()->getMorphClass(),
|
||||
'role_id' => '2',
|
||||
'action' => 'view'
|
||||
]);
|
||||
@ -411,7 +413,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
->seeInDatabase('books', ['id' => $book->id, 'restricted' => true])
|
||||
->seeInDatabase('entity_permissions', [
|
||||
'restrictable_id' => $book->id,
|
||||
'restrictable_type' => 'BookStack\Book',
|
||||
'restrictable_type' => Book::newModelInstance()->getMorphClass(),
|
||||
'role_id' => '2',
|
||||
'action' => 'view'
|
||||
]);
|
||||
@ -419,7 +421,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_restriction_form()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$this->asAdmin()->visit($chapter->getUrl() . '/permissions')
|
||||
->see('Chapter Permissions')
|
||||
->check('restricted')
|
||||
@ -428,7 +430,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
->seeInDatabase('chapters', ['id' => $chapter->id, 'restricted' => true])
|
||||
->seeInDatabase('entity_permissions', [
|
||||
'restrictable_id' => $chapter->id,
|
||||
'restrictable_type' => 'BookStack\Chapter',
|
||||
'restrictable_type' => Chapter::newModelInstance()->getMorphClass(),
|
||||
'role_id' => '2',
|
||||
'action' => 'update'
|
||||
]);
|
||||
@ -436,7 +438,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_page_restriction_form()
|
||||
{
|
||||
$page = \BookStack\Page::first();
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
$this->asAdmin()->visit($page->getUrl() . '/permissions')
|
||||
->see('Page Permissions')
|
||||
->check('restricted')
|
||||
@ -445,7 +447,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
->seeInDatabase('pages', ['id' => $page->id, 'restricted' => true])
|
||||
->seeInDatabase('entity_permissions', [
|
||||
'restrictable_id' => $page->id,
|
||||
'restrictable_type' => 'BookStack\Page',
|
||||
'restrictable_type' => Page::newModelInstance()->getMorphClass(),
|
||||
'role_id' => '2',
|
||||
'action' => 'delete'
|
||||
]);
|
||||
@ -453,7 +455,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_restricted_pages_not_visible_in_book_navigation_on_pages()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$page = $chapter->pages->first();
|
||||
$page2 = $chapter->pages[2];
|
||||
|
||||
@ -466,7 +468,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_restricted_pages_not_visible_in_book_navigation_on_chapters()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$page = $chapter->pages->first();
|
||||
|
||||
$this->setEntityRestrictions($page, []);
|
||||
@ -478,7 +480,7 @@ class RestrictionsTest extends BrowserKitTest
|
||||
|
||||
public function test_restricted_pages_not_visible_on_chapter_pages()
|
||||
{
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = Chapter::first();
|
||||
$page = $chapter->pages->first();
|
||||
|
||||
$this->setEntityRestrictions($page, []);
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Bookshelf;
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\PermissionsRepo;
|
||||
use BookStack\Role;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Auth\Permissions\PermissionsRepo;
|
||||
use BookStack\Auth\Role;
|
||||
use Laravel\BrowserKitTesting\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@ -24,7 +24,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_cannot_delete_admin_role()
|
||||
{
|
||||
$adminRole = \BookStack\Role::getRole('admin');
|
||||
$adminRole = \BookStack\Auth\Role::getRole('admin');
|
||||
$deletePageUrl = '/settings/roles/delete/' . $adminRole->id;
|
||||
$this->asAdmin()->visit($deletePageUrl)
|
||||
->press('Confirm')
|
||||
@ -108,7 +108,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_restrictions_manage_all_permission()
|
||||
{
|
||||
$page = \BookStack\Page::take(1)->get()->first();
|
||||
$page = \BookStack\Entities\Page::take(1)->get()->first();
|
||||
$this->actingAs($this->user)->visit($page->getUrl())
|
||||
->dontSee('Permissions')
|
||||
->visit($page->getUrl() . '/permissions')
|
||||
@ -122,7 +122,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_restrictions_manage_own_permission()
|
||||
{
|
||||
$otherUsersPage = \BookStack\Page::first();
|
||||
$otherUsersPage = \BookStack\Entities\Page::first();
|
||||
$content = $this->createEntityChainBelongingToUser($this->user);
|
||||
// Check can't restrict other's content
|
||||
$this->actingAs($this->user)->visit($otherUsersPage->getUrl())
|
||||
@ -214,7 +214,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_bookshelves_edit_all_permission()
|
||||
{
|
||||
$otherShelf = \BookStack\Bookshelf::first();
|
||||
$otherShelf = \BookStack\Entities\Bookshelf::first();
|
||||
$this->checkAccessPermission('bookshelf-update-all', [
|
||||
$otherShelf->getUrl('/edit')
|
||||
], [
|
||||
@ -225,7 +225,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_bookshelves_delete_own_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['bookshelf-update-all']);
|
||||
$otherShelf = \BookStack\Bookshelf::first();
|
||||
$otherShelf = \BookStack\Entities\Bookshelf::first();
|
||||
$ownShelf = $this->newShelf(['name' => 'test-shelf', 'slug' => 'test-shelf']);
|
||||
$ownShelf->forceFill(['created_by' => $this->user->id, 'updated_by' => $this->user->id])->save();
|
||||
$this->regenEntityPermissions($ownShelf);
|
||||
@ -249,7 +249,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_bookshelves_delete_all_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['bookshelf-update-all']);
|
||||
$otherShelf = \BookStack\Bookshelf::first();
|
||||
$otherShelf = \BookStack\Entities\Bookshelf::first();
|
||||
$this->checkAccessPermission('bookshelf-delete-all', [
|
||||
$otherShelf->getUrl('/delete')
|
||||
], [
|
||||
@ -279,7 +279,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_books_edit_own_permission()
|
||||
{
|
||||
$otherBook = \BookStack\Book::take(1)->get()->first();
|
||||
$otherBook = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
|
||||
$this->checkAccessPermission('book-update-own', [
|
||||
$ownBook->getUrl() . '/edit'
|
||||
@ -295,7 +295,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_books_edit_all_permission()
|
||||
{
|
||||
$otherBook = \BookStack\Book::take(1)->get()->first();
|
||||
$otherBook = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$this->checkAccessPermission('book-update-all', [
|
||||
$otherBook->getUrl() . '/edit'
|
||||
], [
|
||||
@ -306,7 +306,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_books_delete_own_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['book-update-all']);
|
||||
$otherBook = \BookStack\Book::take(1)->get()->first();
|
||||
$otherBook = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
|
||||
$this->checkAccessPermission('book-delete-own', [
|
||||
$ownBook->getUrl() . '/delete'
|
||||
@ -327,7 +327,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_books_delete_all_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['book-update-all']);
|
||||
$otherBook = \BookStack\Book::take(1)->get()->first();
|
||||
$otherBook = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$this->checkAccessPermission('book-delete-all', [
|
||||
$otherBook->getUrl() . '/delete'
|
||||
], [
|
||||
@ -342,7 +342,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_create_own_permissions()
|
||||
{
|
||||
$book = \BookStack\Book::take(1)->get()->first();
|
||||
$book = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$ownBook = $this->createEntityChainBelongingToUser($this->user)['book'];
|
||||
$this->checkAccessPermission('chapter-create-own', [
|
||||
$ownBook->getUrl('/create-chapter')
|
||||
@ -364,7 +364,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_create_all_permissions()
|
||||
{
|
||||
$book = \BookStack\Book::take(1)->get()->first();
|
||||
$book = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$this->checkAccessPermission('chapter-create-all', [
|
||||
$book->getUrl('/create-chapter')
|
||||
], [
|
||||
@ -380,7 +380,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_edit_own_permission()
|
||||
{
|
||||
$otherChapter = \BookStack\Chapter::take(1)->get()->first();
|
||||
$otherChapter = \BookStack\Entities\Chapter::take(1)->get()->first();
|
||||
$ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
|
||||
$this->checkAccessPermission('chapter-update-own', [
|
||||
$ownChapter->getUrl() . '/edit'
|
||||
@ -396,7 +396,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_chapter_edit_all_permission()
|
||||
{
|
||||
$otherChapter = \BookStack\Chapter::take(1)->get()->first();
|
||||
$otherChapter = \BookStack\Entities\Chapter::take(1)->get()->first();
|
||||
$this->checkAccessPermission('chapter-update-all', [
|
||||
$otherChapter->getUrl() . '/edit'
|
||||
], [
|
||||
@ -407,7 +407,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_chapter_delete_own_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['chapter-update-all']);
|
||||
$otherChapter = \BookStack\Chapter::take(1)->get()->first();
|
||||
$otherChapter = \BookStack\Entities\Chapter::take(1)->get()->first();
|
||||
$ownChapter = $this->createEntityChainBelongingToUser($this->user)['chapter'];
|
||||
$this->checkAccessPermission('chapter-delete-own', [
|
||||
$ownChapter->getUrl() . '/delete'
|
||||
@ -429,7 +429,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_chapter_delete_all_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['chapter-update-all']);
|
||||
$otherChapter = \BookStack\Chapter::take(1)->get()->first();
|
||||
$otherChapter = \BookStack\Entities\Chapter::take(1)->get()->first();
|
||||
$this->checkAccessPermission('chapter-delete-all', [
|
||||
$otherChapter->getUrl() . '/delete'
|
||||
], [
|
||||
@ -445,8 +445,8 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_page_create_own_permissions()
|
||||
{
|
||||
$book = \BookStack\Book::first();
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$book = \BookStack\Entities\Book::first();
|
||||
$chapter = \BookStack\Entities\Chapter::first();
|
||||
|
||||
$entities = $this->createEntityChainBelongingToUser($this->user);
|
||||
$ownBook = $entities['book'];
|
||||
@ -470,7 +470,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
foreach ($accessUrls as $index => $url) {
|
||||
$this->actingAs($this->user)->visit($url);
|
||||
$expectedUrl = \BookStack\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
|
||||
$expectedUrl = \BookStack\Entities\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
|
||||
$this->seePageIs($expectedUrl);
|
||||
}
|
||||
|
||||
@ -492,8 +492,8 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_page_create_all_permissions()
|
||||
{
|
||||
$book = \BookStack\Book::take(1)->get()->first();
|
||||
$chapter = \BookStack\Chapter::take(1)->get()->first();
|
||||
$book = \BookStack\Entities\Book::take(1)->get()->first();
|
||||
$chapter = \BookStack\Entities\Chapter::take(1)->get()->first();
|
||||
$baseUrl = $book->getUrl() . '/page';
|
||||
$createUrl = $book->getUrl('/create-page');
|
||||
|
||||
@ -514,7 +514,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
foreach ($accessUrls as $index => $url) {
|
||||
$this->actingAs($this->user)->visit($url);
|
||||
$expectedUrl = \BookStack\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
|
||||
$expectedUrl = \BookStack\Entities\Page::where('draft', '=', true)->orderBy('id', 'desc')->first()->getUrl();
|
||||
$this->seePageIs($expectedUrl);
|
||||
}
|
||||
|
||||
@ -533,7 +533,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_page_edit_own_permission()
|
||||
{
|
||||
$otherPage = \BookStack\Page::take(1)->get()->first();
|
||||
$otherPage = \BookStack\Entities\Page::take(1)->get()->first();
|
||||
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
|
||||
$this->checkAccessPermission('page-update-own', [
|
||||
$ownPage->getUrl() . '/edit'
|
||||
@ -549,7 +549,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_page_edit_all_permission()
|
||||
{
|
||||
$otherPage = \BookStack\Page::take(1)->get()->first();
|
||||
$otherPage = \BookStack\Entities\Page::take(1)->get()->first();
|
||||
$this->checkAccessPermission('page-update-all', [
|
||||
$otherPage->getUrl() . '/edit'
|
||||
], [
|
||||
@ -560,7 +560,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_page_delete_own_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['page-update-all']);
|
||||
$otherPage = \BookStack\Page::take(1)->get()->first();
|
||||
$otherPage = \BookStack\Entities\Page::take(1)->get()->first();
|
||||
$ownPage = $this->createEntityChainBelongingToUser($this->user)['page'];
|
||||
$this->checkAccessPermission('page-delete-own', [
|
||||
$ownPage->getUrl() . '/delete'
|
||||
@ -582,7 +582,7 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_page_delete_all_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['page-update-all']);
|
||||
$otherPage = \BookStack\Page::take(1)->get()->first();
|
||||
$otherPage = \BookStack\Entities\Page::take(1)->get()->first();
|
||||
$this->checkAccessPermission('page-delete-all', [
|
||||
$otherPage->getUrl() . '/delete'
|
||||
], [
|
||||
@ -598,7 +598,7 @@ class RolesTest extends BrowserKitTest
|
||||
|
||||
public function test_public_role_visible_in_user_edit_screen()
|
||||
{
|
||||
$user = \BookStack\User::first();
|
||||
$user = \BookStack\Auth\User::first();
|
||||
$this->asAdmin()->visit('/settings/users/' . $user->id)
|
||||
->seeElement('#roles-admin')
|
||||
->seeElement('#roles-public');
|
||||
@ -633,8 +633,8 @@ class RolesTest extends BrowserKitTest
|
||||
public function test_image_delete_own_permission()
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['image-update-all']);
|
||||
$page = \BookStack\Page::first();
|
||||
$image = factory(\BookStack\Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $this->user->id, 'updated_by' => $this->user->id]);
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
$image = factory(\BookStack\Uploads\Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $this->user->id, 'updated_by' => $this->user->id]);
|
||||
|
||||
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
|
||||
->seeStatusCode(403);
|
||||
@ -650,8 +650,8 @@ class RolesTest extends BrowserKitTest
|
||||
{
|
||||
$this->giveUserPermissions($this->user, ['image-update-all']);
|
||||
$admin = $this->getAdmin();
|
||||
$page = \BookStack\Page::first();
|
||||
$image = factory(\BookStack\Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
$image = factory(\BookStack\Uploads\Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
|
||||
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)
|
||||
->seeStatusCode(403);
|
||||
@ -672,7 +672,7 @@ class RolesTest extends BrowserKitTest
|
||||
{
|
||||
// To cover issue fixed in f99c8ff99aee9beb8c692f36d4b84dc6e651e50a.
|
||||
$page = Page::first();
|
||||
$viewerRole = \BookStack\Role::getRole('viewer');
|
||||
$viewerRole = \BookStack\Auth\Role::getRole('viewer');
|
||||
$viewer = $this->getViewer();
|
||||
$this->actingAs($viewer)->visit($page->getUrl())->assertResponseStatus(200);
|
||||
|
||||
@ -690,14 +690,14 @@ class RolesTest extends BrowserKitTest
|
||||
{
|
||||
$admin = $this->getAdmin();
|
||||
// Book links
|
||||
$book = factory(\BookStack\Book::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
$book = factory(\BookStack\Entities\Book::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
$this->updateEntityPermissions($book);
|
||||
$this->actingAs($this->getViewer())->visit($book->getUrl())
|
||||
->dontSee('Create a new page')
|
||||
->dontSee('Add a chapter');
|
||||
|
||||
// Chapter links
|
||||
$chapter = factory(\BookStack\Chapter::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
|
||||
$chapter = factory(\BookStack\Entities\Chapter::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
|
||||
$this->updateEntityPermissions($chapter);
|
||||
$this->actingAs($this->getViewer())->visit($chapter->getUrl())
|
||||
->dontSee('Create a new page')
|
||||
@ -781,7 +781,7 @@ class RolesTest extends BrowserKitTest
|
||||
}
|
||||
|
||||
private function addComment($page) {
|
||||
$comment = factory(\BookStack\Comment::class)->make();
|
||||
$comment = factory(\BookStack\Actions\Comment::class)->make();
|
||||
$url = "/ajax/page/$page->id/comment";
|
||||
$request = [
|
||||
'text' => $comment->text,
|
||||
@ -794,7 +794,7 @@ class RolesTest extends BrowserKitTest
|
||||
}
|
||||
|
||||
private function updateComment($commentId) {
|
||||
$comment = factory(\BookStack\Comment::class)->make();
|
||||
$comment = factory(\BookStack\Actions\Comment::class)->make();
|
||||
$url = "/ajax/comment/$commentId";
|
||||
$request = [
|
||||
'text' => $comment->text,
|
||||
|
@ -6,18 +6,18 @@ class PublicActionTest extends BrowserKitTest
|
||||
public function test_app_not_public()
|
||||
{
|
||||
$this->setSettings(['app-public' => 'false']);
|
||||
$book = \BookStack\Book::orderBy('name', 'asc')->first();
|
||||
$book = \BookStack\Entities\Book::orderBy('name', 'asc')->first();
|
||||
$this->visit('/books')->seePageIs('/login');
|
||||
$this->visit($book->getUrl())->seePageIs('/login');
|
||||
|
||||
$page = \BookStack\Page::first();
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
$this->visit($page->getUrl())->seePageIs('/login');
|
||||
}
|
||||
|
||||
public function test_books_viewable()
|
||||
{
|
||||
$this->setSettings(['app-public' => 'true']);
|
||||
$books = \BookStack\Book::orderBy('name', 'asc')->take(10)->get();
|
||||
$books = \BookStack\Entities\Book::orderBy('name', 'asc')->take(10)->get();
|
||||
$bookToVisit = $books[1];
|
||||
|
||||
// Check books index page is showing
|
||||
@ -34,7 +34,7 @@ class PublicActionTest extends BrowserKitTest
|
||||
public function test_chapters_viewable()
|
||||
{
|
||||
$this->setSettings(['app-public' => 'true']);
|
||||
$chapterToVisit = \BookStack\Chapter::first();
|
||||
$chapterToVisit = \BookStack\Entities\Chapter::first();
|
||||
$pageToVisit = $chapterToVisit->pages()->first();
|
||||
|
||||
// Check chapters index page is showing
|
||||
@ -52,15 +52,15 @@ class PublicActionTest extends BrowserKitTest
|
||||
public function test_public_page_creation()
|
||||
{
|
||||
$this->setSettings(['app-public' => 'true']);
|
||||
$publicRole = \BookStack\Role::getSystemRole('public');
|
||||
$publicRole = \BookStack\Auth\Role::getSystemRole('public');
|
||||
// Grant all permissions to public
|
||||
$publicRole->permissions()->detach();
|
||||
foreach (\BookStack\RolePermission::all() as $perm) {
|
||||
foreach (\BookStack\Auth\Permissions\RolePermission::all() as $perm) {
|
||||
$publicRole->attachPermission($perm);
|
||||
}
|
||||
$this->app[\BookStack\Services\PermissionService::class]->buildJointPermissionForRole($publicRole);
|
||||
$this->app[\BookStack\Auth\Permissions\PermissionService::class]->buildJointPermissionForRole($publicRole);
|
||||
|
||||
$chapter = \BookStack\Chapter::first();
|
||||
$chapter = \BookStack\Entities\Chapter::first();
|
||||
$this->visit($chapter->book->getUrl());
|
||||
$this->visit($chapter->getUrl())
|
||||
->click('New Page')
|
||||
@ -71,7 +71,7 @@ class PublicActionTest extends BrowserKitTest
|
||||
'name' => 'My guest page'
|
||||
])->seePageIs($chapter->book->getUrl('/page/my-guest-page/edit'));
|
||||
|
||||
$user = \BookStack\User::getDefault();
|
||||
$user = \BookStack\Auth\User::getDefault();
|
||||
$this->seeInDatabase('pages', [
|
||||
'name' => 'My guest page',
|
||||
'chapter_id' => $chapter->id,
|
||||
@ -82,7 +82,7 @@ class PublicActionTest extends BrowserKitTest
|
||||
|
||||
public function test_content_not_listed_on_404_for_public_users()
|
||||
{
|
||||
$page = \BookStack\Page::first();
|
||||
$page = \BookStack\Entities\Page::first();
|
||||
$this->asAdmin()->visit($page->getUrl());
|
||||
\Auth::logout();
|
||||
view()->share('pageTitle', '');
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Book;
|
||||
use BookStack\Bookshelf;
|
||||
use BookStack\Chapter;
|
||||
use BookStack\Entity;
|
||||
use BookStack\Page;
|
||||
use BookStack\Repos\EntityRepo;
|
||||
use BookStack\Repos\PermissionsRepo;
|
||||
use BookStack\Role;
|
||||
use BookStack\Services\PermissionService;
|
||||
use BookStack\Services\SettingService;
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Entity;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\EntityRepo;
|
||||
use BookStack\Auth\Permissions\PermissionsRepo;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Settings\SettingService;
|
||||
|
||||
trait SharedTestHelpers
|
||||
{
|
||||
@ -67,7 +67,7 @@ trait SharedTestHelpers
|
||||
*/
|
||||
protected function getViewer($attributes = [])
|
||||
{
|
||||
$user = \BookStack\Role::getRole('viewer')->users()->first();
|
||||
$user = \BookStack\Auth\Role::getRole('viewer')->users()->first();
|
||||
if (!empty($attributes)) $user->forceFill($attributes)->save();
|
||||
return $user;
|
||||
}
|
||||
@ -85,7 +85,7 @@ trait SharedTestHelpers
|
||||
/**
|
||||
* Create and return a new bookshelf.
|
||||
* @param array $input
|
||||
* @return Bookshelf
|
||||
* @return \BookStack\Entities\Bookshelf
|
||||
*/
|
||||
public function newShelf($input = ['name' => 'test shelf', 'description' => 'My new test shelf']) {
|
||||
return $this->app[EntityRepo::class]->createFromInput('bookshelf', $input, false);
|
||||
@ -104,7 +104,7 @@ trait SharedTestHelpers
|
||||
* Create and return a new test chapter
|
||||
* @param array $input
|
||||
* @param Book $book
|
||||
* @return Chapter
|
||||
* @return \BookStack\Entities\Chapter
|
||||
*/
|
||||
public function newChapter($input = ['name' => 'test chapter', 'description' => 'My new test chapter'], Book $book) {
|
||||
return $this->app[EntityRepo::class]->createFromInput('chapter', $input, $book);
|
||||
@ -164,10 +164,10 @@ trait SharedTestHelpers
|
||||
|
||||
/**
|
||||
* Give the given user some permissions.
|
||||
* @param \BookStack\User $user
|
||||
* @param \BookStack\Auth\User $user
|
||||
* @param array $permissions
|
||||
*/
|
||||
protected function giveUserPermissions(\BookStack\User $user, $permissions = [])
|
||||
protected function giveUserPermissions(\BookStack\Auth\User $user, $permissions = [])
|
||||
{
|
||||
$newRole = $this->createNewRole($permissions);
|
||||
$user->attachRole($newRole);
|
||||
|
@ -7,7 +7,7 @@ class UserProfileTest extends BrowserKitTest
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = \BookStack\User::all()->last();
|
||||
$this->user = \BookStack\Auth\User::all()->last();
|
||||
}
|
||||
|
||||
public function test_profile_page_shows_name()
|
||||
@ -87,7 +87,7 @@ class UserProfileTest extends BrowserKitTest
|
||||
|
||||
public function test_guest_profile_cannot_be_deleted()
|
||||
{
|
||||
$guestUser = \BookStack\User::getDefault();
|
||||
$guestUser = \BookStack\Auth\User::getDefault();
|
||||
$this->asAdmin()->visit('/settings/users/' . $guestUser->id . '/delete')
|
||||
->see('Delete User')->see('Guest')
|
||||
->press('Confirm')
|
||||
|
Reference in New Issue
Block a user