text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|><?php
namespace Tests\Auth;
use BookStack\Access\GroupSyncService;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Tests\TestCase;
class GroupSyncServiceTest extends TestCase
{
public function test_user_is_assigned_to_matching_roles()
{
$user = $this->users->viewer... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Auth;
use BookStack\Access\Ldap;
use BookStack\Access\LdapService;
use BookStack\Exceptions\LdapException;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Illuminate\Testing\TestResponse;
use Mockery\MockInterface;
use Tests\TestCase;
class LdapTest extends T... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>nit=true');
$req->assertDontSeeText('Attempting Login');
$req->assertSee('Log In');
}
public function test_logout_with_auto_init_leads_to_login_page_with_prevention_query()
{
config()->set([
'auth.method' => 'oidc',
]);
$this->actingAs($this... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Auth;
use BookStack\Access\Mfa\MfaValue;
use BookStack\Activity\ActivityType;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Hash;
use PragmaRX\Google2FA\Google2FA;
use Tests\TestCase;
class MfaConfigurationTest extends TestCase
{
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>method.');
$resp = $this->followingRedirects()->post('/login', [
'email' => $user->email,
'password' => 'password',
]);
$resp->assertSeeText('Enter one of your remaining backup codes below:');
}
public function test_mfa_setup_route_access()
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ta provided by the external authentication system');
}
public function test_auth_fails_if_already_logged_in()
{
$this->asEditor();
$this->runLogin([
'email' => 'benny@example.com',
'sub' => 'benny505',
]);
$this->assertSessionError('... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>il' => 'barrybot@example.com',
'password' => 'barryIsTheBestBot',
'username' => 'MyUsername'
]);
$resp->assertRedirect('/register');
$resp = $this->followRedirects($resp);
$this->withHtml($resp)->assertElementExists('form input[name="username"].text... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>test_reset_request_is_throttled()
{
$editor = $this->users->editor();
Notification::fake();
$this->get('/password/email');
$this->followingRedirects()->post('/password/email', [
'email' => $editor->email,
]);
$resp = $this->followingRedirect... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Auth;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Tests\TestCase;
class Saml2Test extends TestCase
{
protected function setUp(): void
{
parent::setUp();
// Set default config for SAML2
config()->set([
'auth.meth... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Auth;
use BookStack\Access\SocialAccount;
use BookStack\Activity\ActivityType;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\DB;
use Laravel\Socialite\Contracts\Factory;
use Laravel\Socialite\Contracts\Provider;
use Mockery;
use Tests\TestCase;
class SocialAuthTe... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Auth;
use BookStack\Access\Notifications\UserInviteNotification;
use BookStack\Access\UserInviteService;
use BookStack\Users\Models\User;
use Carbon\Carbon;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Notifica... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> $booksWithoutSort = Book::query()->whereNull('sort_rule_id')->count();
$this->assertEquals(0, $booksWithoutSort);
$this->assertEquals($totalBooks, $sortRuleB->books()->count() + 1);
}
public function test_assign_to_all_books_with_sort()
{
$book = $this->entitie... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use BookStack\Uploads\Image;
use Tests\TestCase;
class CleanupImagesCommandTest extends TestCase
{
public function test_command_defaults_to_dry_run()
{
$page = $this->entities->page();
$image = Image::factory()->create(['uploaded_to' => $page->id]... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Commands;
use BookStack\Activity\ActivityType;
use BookStack\Facades\Activity;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ClearActivityCommandTest extends TestCase
{
public function test_clear_activity_command()
{
$this->... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Repos\PageRepo;
use Illuminate\Support\Facades\Artisan;
use Tests\TestCase;
class ClearRevisionsCommandTest extends TestCase
{
public function test_clear_<|fim_suffix|>y' => 'page revision testing']);
... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Commands;
use BookStack\Entities\Models\Page;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ClearViewsCommandTest extends TestCase
{
public function test_clear_views_command()
{
$this->asEditor();
$page = Page::first();
$this->get($page->getUrl())... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use Tests\TestCase;
class CopyShelfPermissionsCommandTest extends TestCase
{
public function test_copy_shelf_permissions_command_shows_error_when_no_required_option_given()
{
$th... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
class CreateAdminCommandTest extends TestCase
{
public function tes... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>$normalUsers->first()->id]);
}
protected function getNormalUsers(): Collection
{
return User::query()->whereNull('system_name')
->get()
->filter(function (User $user) {
return !$user->hasSystemRole('admin');
});
}
}
<|fim_prefix|... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\File;
use Tests\TestCase;
use ZipArchive;
class InstallModuleCommandTest extends TestCase
{
public function test_local_module_install_with_active_theme()
{
$this->usingThemeFolder(function () {
... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Commands;
use BookStack\Uploads\Image;
use BookStack\Users\Models\User;
use GuzzleHttp\Psr7\Response;
use Illuminate\Database\Eloquent\Collection;
use Tests\TestCase;
class RefreshAvatarCommandTest extends TestCase
{
public function setUp(): void
{
parent::setUp();
conf... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Commands;
use BookStack\Auth\Permissions\CollapsedPermission;
use BookStack\Permissions\Models\JointPermission;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class RegeneratePermissionsCommandTest extends TestCase
{
public function test_regen... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class RegenerateReferencesCommandTest extends TestCase
{
public function test_regenerate_references_command()
{
$page = $this->entities->page();
$book = $page->book;
$page->html = '<a... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Commands;
use BookStack\Search\SearchTerm;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class RegenerateSearchCommandTest extends TestCase
{
public function test_command_regenerates_index()
{
DB::rollBack();
$page = $this->entities->page();
SearchTerm::... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>r = User::query()->first();
MfaValue::upsertWithValue($user, MfaValue::METHOD_TOTP, 'test');
$this->assertEquals(1, $user->mfaValues()->count());
$this->artisan("bookstack:reset-mfa --id={$user->id}")
->expectsQuestion('Are you sure you want to proceed?', true)
... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Commands;
use BookStack\En<|fim_suffix|>:update-url {$oldUrl} {$newUrl}")
->expectsQuestion("This will search for \"{$oldUrl}\" in your database and replace it with \"{$newUrl}\".\nAre you sure you want to proceed?", 'y')
->expectsQuestion('This operation c... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ntain('ALTER DATABASE')
->expectsOutputToContain('ALTER TABLE `users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
}
}
<|fim_prefix|><?php
namespace Tests\Commands;
use Tests\TestCase;
class UpgradeDatabaseEncodingCommandTest extends TestCase
{
public function tes... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminat<|fim_suffix|> = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}
<|fim_middle|>e\Foundation\Application;
trait CreatesApplication
{
/**
* Create... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests;
use BookStack\Access\SocialDriverManager;
use Illuminate\Testing\TestResponse;
class DebugViewTest extends TestCase
{
public function test_debug_view_shows_expected_details()
{
config()->set('app.debug', true);
$resp = $this->getDebugViewForException(new \... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>e, 'update' => true, 'create' => false, 'delete' => false,
]);
}
public function test_permission_page_has_a_warning_about_no_cascading()
{
$shelf = $this->entities->shelf();
$resp = $this->asAdmin()->get($shelf->getUrl('/permissions'));
$resp->assertSeeText('Pe... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> 'value' => 'Dolphin Content',
],
[
'name' => 'Level',
'value' => '5',
],
],
]);
$book->refresh();
$tags = $book->tags()->get();
$this->assertEquals(2, $tags->count());
... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use Tests\TestCa<|fim_suffix|>);
$resp = $this->asEditor()->get($chapter->getUrl());
$resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwit... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ildPage->refresh();
$this->assertEquals(0, $chapterChildPage->chapter_id);
$this->assertEquals($childChapter->name, $chapterChildPage->book->name);
}
public function test_book_convert_to_shelf_requires_permissions()
{
$book = $this->entities->book();
$user = $t... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ng($newPage->getUrl(), $newPage->html);
$this->assertStringNotContainsString($page->getUrl(), $newPage->html);
}
public function test_page_copy()
{
$page = $this->entities->page();
$page->html = '<p>This is some test content</p>';
$page->save();
$curre... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>tBookPage->markdown);
$this->asEditor()->get($chapter->getUrl('/create-page'));
$latestChapterPage = $chapter->pages()
->where('draft', '=', true)
->where('template', '=', false)
->latest()->first();
$this->assertEquals('', $latestChapterPage->... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Entities\Models\Entity;
use BookStack\Us<|fim_suffix|>d revisions
$creator = $this->users->viewer();
$updater = $this->users->editor();
$entities = $this->entities->createChainBelongingToUser($creator, $updater);
app()->make(Use... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Entity;
use BookStack\Entities\Models\Book;
use Illuminate\Database\Eloquent\Builder;
use Tests\TestCase;
class EntityQueryTest extends TestCase
{
public function test_basic_entity_query_has_join_and_type_applied()
{
$query = Book::query();
$expected = 'select * from `en... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>n```JavaScript\nvar a = 'cat';\n```\n\nAnother line"
);
}
public function test_tasklist_checkboxes_are_handled()
{
$this->assertConversion(
'<ul><li><input type="checkbox" checked="checked">Item A</li><li><input type="checkbox">Item B</li></ul>',
"- [x]... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> config()->set('app.content_filtering', 'a');
$resp = $this->get($page->getUrl());
$resp->assertDontSee('style="position: absolute; left: 0;color:#00FFEE;"', false);
$resp->assertSee('style="color:#00FFEE;"', false);
}
public function test_allow_list_style_filtering(... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>h);
$this->assertEquals(base64_decode($this->base64Jpeg), file_get_contents($imageFile));
$this->files->deleteAtRelativePath($imagePath);
}
public function test_markdown_base64_extract_not_limited_by_pcre_limits()
{
$pcreBacktrackLimit = ini_get('pcre.backtrack_limit'... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> 'type' => 'update_draft',
'created_by' => $editor->id,
'page_id' => $page->id,
];
$this->assertDatabaseHas('page_revisions', $revisionData);
$resp = $this->delete("/page-revisions/user-drafts/{$page->id}");
$resp->assertOk();
$this->asser... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>editor_permissions()
{
$page = $this->entities->page();
$page->html = '<h2>A Header</h2><p>Some <strong>bold</strong> content.</p>';
$page->editor = 'wysiwyg';
$page->save();
$this->asEditor()->put($page->getUrl(), ['name' => $page->name, 'markdown' => '## Upda... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Activity\ActivityType;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Models\PageRevision;
use BookStack\Permissions\Permission;
use Tests\TestCase;
class PageRevisionTest extends TestCase
{
public function test_revision_links_visible_to_viewe... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Entities\Model<|fim_suffix|> $templateView = $this->get($page->getUrl());
$templateView->assertDontSee('Page Template');
$page->template = true;
$page->save();
$templateView = $this->get($page->getUrl());
$templ... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Page;
use BookStack\Uploads\Image;
use Carbon\Carbon;
use Tests\TestCase;
class PageTest extends TestCase
{
public function test_create()
{
$chapter = $this->entities->chapter();
$pag... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Entities\Models\SlugHistory;
use Tests\TestCase;
class SlugTest extends TestCase
{
public function test_slug_multi_byte_url_safe()
{
$book = $this->entities->newBook([
'name' => 'информация',
]);
$this->assertEqual... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Entity;
use BookStack\Activity\Models\Tag;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
use Tests\TestCase;
class TagTest extends TestCase
{
protected int $defaultTagCount = 20;
/**
* Get an instance of a page that has many tags.
*/
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ication/json',
]);
$resp->assertStatus(413);
$resp->assertJson(['error' => 'The server cannot receive the provided amount of data. Try again with less data or a smaller file.']);
}
}
<|fim_prefix|><?php
namespace Tests;
use Illuminate\Support\Facades\Log;
class ErrorTest ex... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ntity) {
$resp = $this->get($entity->getUrl());
$resp->assertDontSee('/export/pdf');
$resp = $this->get($entity->getUrl('/export/pdf'));
$this->assertPermissionError($resp);
}
}
}
<|fim_prefix|><?php
namespace Tests\Exports;
use BookStack\Entit... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Exports;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Permissions\Permission;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class HtmlExportTest extends TestCase
{
public function tes... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Exports;
use BookStack\Entities\Models\Book;
use Tests\TestCase;
class MarkdownExportTest extends TestCase
{
public function test_page_markdown_export()
{
$page = $this->entities->page();
$resp = $this->asEditor()->get($page->getUrl('/export/markdown'));
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>erator->shouldReceive('getActiveEngine')->andReturn(PdfGenerator::ENGINE_DOMPDF);
$this->asEditor()->get($page->getUrl('/export/pdf'));
$this->assertStringContainsString('<details open="open"', $pdfHtml);
}
public function test_custom_fonts_loaded_for_dom_pdf_when_used()
{
... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Exports;
use Tests\TestCase;
class TextExportTest extends TestCase
{
public function test_page_text_export()
{
$page = $this->entities->page();
$this->asEditor();
$resp = $this->get($page->getUrl('/export/plaintext'));
$resp->assertStatus(2... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Exports;
use BookStack\Activity\Models\Tag;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Tools\PageContent;
use BookStack\Uploads\Attachment;
use BookStack\Uploads\Image;
use FilesystemIterator;
use Illuminate\Support\Carbon;
use Illuminate\Testing\TestResponse;
us... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Exports;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Exports\ZipExports\ZipExportReader;
use BookStack\Exports\ZipExports\ZipExportValidator;
use BookStack\Exports\ZipExports\ZipImportRunner;
use BookS... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> ]
],
'images' => [
[
'id' => 2,
'name' => 'Dog Drawing',
'type' => 'drawio',
'file' => 'dog_image'
]
],
... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Exports;
use BookStack\Activity\ActivityType;
use BookStack\Entities\Models\Book;
use BookStack\Exports\Import;
use BookStack\Exports\ZipExports\Models\ZipExportBook;
use BookStack\Exports\ZipExports\Models\ZipExportChapter;
use BookStack\Exports\ZipExports\Models\ZipExportPage;
use Illuminate\H... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> */
public function extractPath(string $path): string
{
$relPath = implode(DIRECTORY_SEPARATOR, explode('/', $path));
return $this->extractedDirPath . DIRECTORY_SEPARATOR . ltrim($relPath, DIRECTORY_SEPARATOR);
}
}
<|fim_prefix|><?php
namespace Tests\Exports;
class ZipResultD... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>h);
$targetDir = dirname($targetPath);
if (!file_exists($targetDir)) {
mkdir($targetDir);
}
rename($zip->getRealPath(), $targetPath);
return $import;
}
public static function deleteZipForImport(Import $import): void
{
$path = stor... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests;
use BookStack\Activity\Models\Favourite;
use BookStack\Users\Models\User;
class FavouriteTest extends TestCase
{
public function test_page_add_favourite_flow()
{
$page = $this->entities->page();
$editor = $this->users->editor();
$resp = $this->act... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Helpers;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Repos\BookshelfRepo;
... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Helpers;
use BookStack\Entities\Models\Page;
use BookStack\Uploads\Attachment;
use BookStack\Uploads\AttachmentService;
use Illuminate\Http\UploadedFile;
use Illuminate\Testing\TestResponse;
use stdClass;
use Tests\TestCase;
class FileProvider
{
/**
* Get the path to a fi... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>N30g5mdf
efqXPwg2wAPYeiec49EbfnteQQKAkqNfJ9K69yE2naf6bw3/5mCBsq/cXeuaBMII
ylysUIRBqt2J0kWm2yCpFWR7H+Ilhdx9A7ZLCqYVt8e+vjO/BOI3cQDe2VPOLPSl
q/1PY4iJviGKddtmfClH3v4=
-----END PRIVATE KEY-----';
}
public static function publicJwkKeyArray(): array
{
return [
'kty' => 'RSA',
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>st, 0);
$this->addEntityPermissionEntries($entity, [$permissionData]);
}
/**
* Disable inherited permissions on the given entity.
* Effectively sets the "Other Users" UI permission option to not inherit, with no permissions.
*/
public function disableEntityInheritedPerm... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> }
}
<|fim_prefix|><?php
namespace Tests\Helpers;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\ParallelTesting;
use Illuminate\Support\ServiceProvider;
class TestServiceProvider<|fim_middle|> extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return v... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> $user = $this->newUser($userAttrs);
$role = $this->attachNewRole($user, $rolePermissions);
return [$user, $role];
}
/**
* Attach a new role, with the given role permissions, to the given user
* and return that role.
*/
public function attachNewRole(User $user... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests;
use BookStack\Users\Models\Role;
use BookStack\Users\Models\User;
class HomepageTest extends TestCase
{
public function test_default_homepage_visible()
{
$this->asEditor();
$homeVisit = $this->get('/');
$homeVisit->assertSee('My Recently Viewed');
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>replace('.php', '', $file), [], $lang);
} catch (\Exception $e) {
$loadError = true;
}
$this->assertFalse($loadError, "Translation file {$lang}/{$file} failed to load");
}
}
}
public function test_views_use_rt... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Meta;
use Tests\TestCase;
class HelpTest extends TestCase
{
public function test_tinymce_help_shows_tiny_and_tiny_license_link()
{
$resp = $this->get('/help/tinymce');
$resp->assertOk();
$this->withHtml($resp)->assertElementExists('a[href="https://www.tiny.cloud/... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Meta;
use Tests\TestCase;
class LicensesTest extends TestCase
{
public function test_licenses_endpoint()
{
$resp = $this->get('/licenses');
$resp->assertOk();
$resp->assertSee('Licenses');
$resp->assertSee('PHP Library Licenses');
$resp->assertSee... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>| BookStack', $tags['title']);
$this->assertEquals($shelf->getUrl(), $tags['url']);
$this->assertEquals(Str::limit($shelf->description, 100, '...'), $tags['description']);
$this->assertArrayNotHasKey('image', $tags);
// Test image set if image has cover image
$base... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Meta;
use Tests\TestCase;
class OpensearchTest extends TestCase
{
public function test_opensearch_endpoint()
{
$appName = 'MyAppNameThatsReallyLongLikeThis';
setting()->put('app-name', $appName);
$resultUrl = url('/search') . '?term={searchTerms}';
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|> $resp->assertJson(['background_color' => '#111111']);
}
}
<|fim_prefix|><?php
namespace Tests\Meta;
use Tests\TestCase;
class PwaManifestTest extends TestCase
{
public function test_manifest_access_and_format()
{
$this->setSettings(['app-color' => '#00ACED']);
$resp = $th... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Meta;
use Tests\TestCase;
class RobotsTest extends TestCase
{
public function test_robots_effected_by_public_status()
{
$this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
$this->setSettings(['app-public' => 'true']);
$resp = $this->get('/robots... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Permissions;
use BookStack\Users\Models\User;
use Tests\TestCase;
class EntityOwnerChangeTest extends TestCase
{
public function test_changing_page_owner()
{
$page = $this->entities->page();
$user = User::query()->where('id', '!=', $page->owned_by)->first();
$th... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>pterUrl . '/delete')->assertOk()->assertSee('Delete Chapter');
$this->get($chapterPage->getUrl() . '/delete')->assertOk()->assertSee('Delete Page');
}
public function test_page_view_restriction()
{
$page = $this->entities->page();
$pageUrl = $page->getUrl();
$... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>apter->getUrl("export/{$format}"));
$resp->assertStatus(200);
$resp->assertDontSee($page->name);
$resp->assertDontSee($pageContent);
}
}
public function test_page_content_without_view_access_hidden_on_book_export()
{
$book = $this->entities-... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Permissions;
use BookStack\Activity\Models\Comment;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
use BookStack\Uploads\Image;
use BookSta... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Permissions\Scenarios;
class EntityRolePermissionsTest extends PermissionScenarioTestCase
{
public function test_01_explicit_allow()
{
[$user, $role] = $this->users->newUserWithRole();
$page = $this->entities->page();
$this->permissions->setEntityPer... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Permissions\Scenarios;
use BookStack\Entities\Models\Entity;
use BookStack\Users\Models\User;
use Tests\TestCase;
// Cases defined in dev/docs/permission-scenario-testing.md
class PermissionScenarioTestCase extends TestCase
{
protected function assertVisibleToUser(Entity $ent... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Permissions\Scenarios;
class RoleContentPermissionsTest extends PermissionScenarioTestCase
{
public function test_01_allow()
{
[$user] = $this->users->newUserWithRole([], ['page-view-all']);
$page = $this->entities->page();
$this->assertVisibleToUse... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>content_not_listed_on_404_for_public_users()
{
$page = $this->entities->page();
$page->fill(['name' => 'my testing random unique page name'])->save();
$this->asAdmin()->get($page->getUrl()); // Fake visit to show on recents
$resp = $this->get('/cats/dogs/hippos');
... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\References;
use BookStack\References\CrossLinkParser;
use Tests\TestCase;
class CrossLinkParserTest extends TestCase
{
public function test_instance_with_entity_resolvers_matches_entity_links()
{
$entities = $this->entities->all();
$otherPage = $this->entities->page();
... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\References;
use BookStack\App\Model;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Entities\Tools\TrashCan;
use BookStack\References\Reference;
use Tests\TestCase;
class ReferencesTest extends TestCase
{
public function test_references_created_on_page_update()
{
... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Search;
use BookStack\Activity\Models\Tag;
use BookStack\Entities\Models\Book;
use Tests\TestCase;
class EntitySearchTest extends TestCase
{
public function test_page_search()
{
$book = $this->entities->book();
$page = $book->pages->first();
$searc... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Search;
use Tests\TestCase;
class SearchIndexingTest extends TestCase
{
public function test_terms_in_headers_have_an_adjusted_index_score()
{
$page = $this->entities->newPage(['name' => 'Test page A', 'html' => '
<p>TermA</p>
<h1>TermB <str... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Search;
use BookStack\Search\Options\ExactSearchOption;
use BookStack\Search\Options\FilterSearchOption;
use BookStack\Search\Options\TagSearchOption;
use BookStack\Search\Options\TermSearchOption;
use BookStack\Search\SearchOptions;
use BookStack\Search\SearchOptionSet;
use Illuminate\Http\Requ... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Search;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use Tests\TestCase;
class SiblingSearchTest extends TestCase
{
public function test_sibling_search_for_pages()
{
$chapter = $this->entities->chapterHasPages();
$this->assertGreaterThan(2... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>src');
$this->assertEquals("style-src 'self'", $header);
}
public function test_img_src_csp_header_set_to_permissive_defaults_when_not_configured()
{
config()->set('app.image_sources', null);
$resp = $this->get('/');
$header = $this->getCspHeader($resp, 'img-s... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>tory()
{
$this->asEditor()->get('/books');
$this->get('/manifest.json');
$this->assertEquals(url('/books'), session()->previousUrl());
}
public function test_dist_dir_access_is_not_tracked_in_session_history()
{
$this->asEditor()->get('/books');
$t... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>ml" nonce="abc123">
const a = `<\script><\/script>`;
const b = `<script`;
</script>
<script nonce="abc123">const b = `↗️£`;</script>
');
$this->setSettings(['app-custom-head' => $content]);
$resp = $this->get('/login');
$resp->assertSee($expectedOutput, false);
}
}
<|f... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>in');
$this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/privacy"]', 'Privacy Policy');
$this->withHtml($resp)->assertElementContains('footer a[href="https://example.com/terms"]', 'Terms of Service');
}
}
<|fim_prefix|><?php
namespace Tests\Settings;
us... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Settings;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use Tests\TestCase;
class PageListLimitsTest extends TestCase
{
public function test_saving_setting_and_loading()
{
$resp = $this->asAdmin()->post('/settings/sorting', [
... | fim | BookStackApp/BookStack | php |
<|fim_suffix|>$route);
$resp = $this->call($method, $url);
$this->assertPermissionError($resp);
}
$this->permissions->grantUserRolePermissions($editor, ['restrictions-manage-all']);
foreach ($routes as $route) {
[$method, $url] = explode(':', $route);
... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Settings;
use BookStack\Activity\ActivityType;
use BookStack\References\ReferenceStore;
use Tests\TestCase;
class RegenerateReferencesTest extends TestCase
{
public function test_option_visible_on_maintenance_page()
{
$pageView = $this->asAdmin()->get('/settings/maintenance');
... | fim | BookStackApp/BookStack | php |
<?php
namespace Tests\Settings;
use Tests\TestCase;
class SettingsTest extends TestCase
{
public function test_admin_can_see_settings()
{
$this->asAdmin()->get('/settings/features')->assertSee('Settings');
}
public function test_settings_endpoint_redirects_to_settings_view()
{
$r... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Settings;
use BookStack\Settings\TestEmailNotification;
use Illuminate\Contracts\Notifications\Dispatcher;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class TestEmailTest extends TestCase
{
public function test_a_send_test_button_shows()
{
$pag... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Sorting;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use BookStack\Entities\Repos\PageRepo;
use BookStack\Sorting\SortRule;
use Tests\TestCase;
class BookSortTest extends TestCase
{
public function test_book_sort_page_shows()
{
$bookT... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Sorting;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Page;
use Tests\TestCase;
class MoveTest extends TestCase
{
public function test_page_move_into_book()
{
$page = $this->entities->page();
$curr... | fim | BookStackApp/BookStack | php |
<|fim_prefix|><?php
namespace Tests\Sorting;
use BookStack\Activity\ActivityType;
use BookStack\Entities\Models\Book;
use BookStack\Sorting\SortRule;
use BookStack\Sorting\SortRuleOperation;
use Tests\Api\TestsApi;
use Tests\TestCase;
class SortRuleTest extends TestCase
{
use TestsApi;
public function test_... | fim | BookStackApp/BookStack | php |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.