1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Laravel 8 shift squash & merge (#3029)

* Temporarily moved back config path
* Apply Laravel coding style
* Shift exception handler
* Shift HTTP kernel and middleware
* Shift service providers
* Convert options array to fluent methods
* Shift to class based routes
* Shift console routes
* Ignore temporary framework files
* Shift to class based factories
* Namespace seeders
* Shift PSR-4 autoloading
* Shift config files
* Default config files
* Shift Laravel dependencies
* Shift return type of base TestCase methods
* Shift cleanup
* Applied stylci style changes
* Reverted config files location
* Applied manual changes to Laravel 8 shift

Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
Dan Brown
2021-10-30 21:29:59 +01:00
committed by GitHub
parent f77236aa38
commit f139cded78
71 changed files with 1349 additions and 916 deletions

View File

@@ -17,7 +17,7 @@ class AuditLogTest extends TestCase
/** @var ActivityService */
protected $activityService;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->activityService = app(ActivityService::class);

View File

@@ -44,7 +44,7 @@ class AuthTest extends TestCase
{
// Set settings and get user instance
$this->setSettings(['registration-enabled' => 'true']);
$user = factory(User::class)->make();
$user = User::factory()->make();
// Test form and ensure user is created
$this->get('/register')
@@ -102,7 +102,7 @@ class AuthTest extends TestCase
// Set settings and get user instance
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true']);
$user = factory(User::class)->make();
$user = User::factory()->make();
// Go through registration process
$resp = $this->post('/register', $user->only('name', 'email', 'password'));
@@ -140,7 +140,7 @@ class AuthTest extends TestCase
public function test_restricted_registration()
{
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true', 'registration-restrict' => 'example.com']);
$user = factory(User::class)->make();
$user = User::factory()->make();
// Go through registration process
$this->post('/register', $user->only('name', 'email', 'password'))
@@ -166,7 +166,7 @@ class AuthTest extends TestCase
public function test_restricted_registration_with_confirmation_disabled()
{
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'false', 'registration-restrict' => 'example.com']);
$user = factory(User::class)->make();
$user = User::factory()->make();
// Go through registration process
$this->post('/register', $user->only('name', 'email', 'password'))

View File

@@ -20,7 +20,7 @@ class LdapTest extends TestCase
protected $mockUser;
protected $resourceId = 'resource-test';
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
if (!defined('LDAP_OPT_REFERRALS')) {
@@ -42,7 +42,7 @@ class LdapTest extends TestCase
]);
$this->mockLdap = \Mockery::mock(Ldap::class);
$this->app[Ldap::class] = $this->mockLdap;
$this->mockUser = factory(User::class)->make();
$this->mockUser = User::factory()->make();
}
protected function runFailedAuthLogin()
@@ -264,9 +264,9 @@ class LdapTest extends TestCase
public function test_login_maps_roles_and_retains_existing_roles()
{
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
$roleToReceive2 = factory(Role::class)->create(['display_name' => 'LdapTester Second']);
$existingRole = factory(Role::class)->create(['display_name' => 'ldaptester-existing']);
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
$roleToReceive2 = Role::factory()->create(['display_name' => 'LdapTester Second']);
$existingRole = Role::factory()->create(['display_name' => 'ldaptester-existing']);
$this->mockUser->forceFill(['external_auth_id' => $this->mockUser->name])->save();
$this->mockUser->attachRole($existingRole);
@@ -310,8 +310,8 @@ class LdapTest extends TestCase
public function test_login_maps_roles_and_removes_old_roles_if_set()
{
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
$existingRole = factory(Role::class)->create(['display_name' => 'ldaptester-existing']);
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
$existingRole = Role::factory()->create(['display_name' => 'ldaptester-existing']);
$this->mockUser->forceFill(['external_auth_id' => $this->mockUser->name])->save();
$this->mockUser->attachRole($existingRole);
@@ -350,15 +350,15 @@ class LdapTest extends TestCase
public function test_external_auth_id_visible_in_roles_page_when_ldap_active()
{
$role = factory(Role::class)->create(['display_name' => 'ldaptester', 'external_auth_id' => 'ex-auth-a, test-second-param']);
$role = Role::factory()->create(['display_name' => 'ldaptester', 'external_auth_id' => 'ex-auth-a, test-second-param']);
$this->asAdmin()->get('/settings/roles/' . $role->id)
->assertSee('ex-auth-a');
}
public function test_login_maps_roles_using_external_auth_ids_if_set()
{
$roleToReceive = factory(Role::class)->create(['display_name' => 'ldaptester', 'external_auth_id' => 'test-second-param, ex-auth-a']);
$roleToNotReceive = factory(Role::class)->create(['display_name' => 'ex-auth-a', 'external_auth_id' => 'test-second-param']);
$roleToReceive = Role::factory()->create(['display_name' => 'ldaptester', 'external_auth_id' => 'test-second-param, ex-auth-a']);
$roleToNotReceive = Role::factory()->create(['display_name' => 'ex-auth-a', 'external_auth_id' => 'test-second-param']);
app('config')->set([
'services.ldap.user_to_groups' => true,
@@ -395,8 +395,8 @@ class LdapTest extends TestCase
public function test_login_group_mapping_does_not_conflict_with_default_role()
{
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
$roleToReceive2 = factory(Role::class)->create(['display_name' => 'LdapTester Second']);
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
$roleToReceive2 = Role::factory()->create(['display_name' => 'LdapTester Second']);
$this->mockUser->forceFill(['external_auth_id' => $this->mockUser->name])->save();
setting()->put('registration-role', $roleToReceive->id);
@@ -641,8 +641,8 @@ class LdapTest extends TestCase
public function test_login_with_email_confirmation_required_maps_groups_but_shows_confirmation_screen()
{
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
$user = factory(User::class)->make();
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
$user = User::factory()->make();
setting()->put('registration-confirmation', 'true');
app('config')->set([

View File

@@ -16,7 +16,7 @@ class OidcTest extends TestCase
protected $keyFilePath;
protected $keyFile;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
// Set default config for OpenID Connect
@@ -41,7 +41,7 @@ class OidcTest extends TestCase
]);
}
public function tearDown(): void
protected function tearDown(): void
{
parent::tearDown();
if (file_exists($this->keyFilePath)) {

View File

@@ -8,7 +8,7 @@ use Tests\TestCase;
class Saml2Test extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
// Set default config for SAML2
@@ -119,7 +119,7 @@ class Saml2Test extends TestCase
'saml2.remove_from_groups' => false,
]);
$memberRole = factory(Role::class)->create(['external_auth_id' => 'member']);
$memberRole = Role::factory()->create(['external_auth_id' => 'member']);
$adminRole = Role::getSystemRole('admin');
$this->followingRedirects()->post('/saml2/acs', ['SAMLResponse' => $this->acsPostData]);
@@ -141,7 +141,7 @@ class Saml2Test extends TestCase
$acsPost = $this->followingRedirects()->post('/saml2/acs', ['SAMLResponse' => $this->acsPostData]);
$user = User::query()->where('external_auth_id', '=', 'user')->first();
$randomRole = factory(Role::class)->create(['external_auth_id' => 'random']);
$randomRole = Role::factory()->create(['external_auth_id' => 'random']);
$user->attachRole($randomRole);
$this->assertContains($randomRole->id, $user->roles()->pluck('id'));
@@ -295,7 +295,7 @@ class Saml2Test extends TestCase
'saml2.remove_from_groups' => false,
]);
$memberRole = factory(Role::class)->create(['external_auth_id' => 'member']);
$memberRole = Role::factory()->create(['external_auth_id' => 'member']);
$adminRole = Role::getSystemRole('admin');
$acsPost = $this->followingRedirects()->post('/saml2/acs', ['SAMLResponse' => $this->acsPostData]);

View File

@@ -15,7 +15,7 @@ class SocialAuthTest extends TestCase
{
public function test_social_registration()
{
$user = factory(User::class)->make();
$user = User::factory()->make();
$this->setSettings(['registration-enabled' => 'true']);
config(['GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
@@ -118,7 +118,7 @@ class SocialAuthTest extends TestCase
'APP_URL' => 'http://localhost',
]);
$user = factory(User::class)->make();
$user = User::factory()->make();
$mockSocialite = $this->mock(Factory::class);
$mockSocialDriver = Mockery::mock(Provider::class);
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
@@ -156,7 +156,7 @@ class SocialAuthTest extends TestCase
'APP_URL' => 'http://localhost', 'services.google.auto_register' => true, 'services.google.auto_confirm' => true,
]);
$user = factory(User::class)->make();
$user = User::factory()->make();
$mockSocialite = $this->mock(Factory::class);
$mockSocialDriver = Mockery::mock(Provider::class);
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
@@ -188,7 +188,7 @@ class SocialAuthTest extends TestCase
public function test_social_registration_with_no_name_uses_email_as_name()
{
$user = factory(User::class)->make(['email' => 'nonameuser@example.com']);
$user = User::factory()->make(['email' => 'nonameuser@example.com']);
$this->setSettings(['registration-enabled' => 'true']);
config(['GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);

View File

@@ -37,7 +37,7 @@ class BookShelfTest extends TestCase
public function test_shelves_shows_in_header_if_have_any_shelve_view_permission()
{
$user = factory(User::class)->create();
$user = User::factory()->create();
$this->giveUserPermissions($user, ['image-create-all']);
$shelf = Bookshelf::first();
$userRole = $user->roles()->first();

View File

@@ -9,7 +9,7 @@ class BookTest extends TestCase
{
public function test_create()
{
$book = factory(Book::class)->make([
$book = Book::factory()->make([
'name' => 'My First Book',
]);
@@ -29,7 +29,7 @@ class BookTest extends TestCase
public function test_create_uses_different_slugs_when_name_reused()
{
$book = factory(Book::class)->make([
$book = Book::factory()->make([
'name' => 'My First Book',
]);

View File

@@ -13,7 +13,7 @@ class ChapterTest extends TestCase
/** @var Book $book */
$book = Book::query()->first();
$chapter = factory(Chapter::class)->make([
$chapter = Chapter::factory()->make([
'name' => 'My First Chapter',
]);

View File

@@ -9,7 +9,7 @@ class CommentSettingTest extends TestCase
{
protected $page;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->page = Page::query()->first();

View File

@@ -13,7 +13,7 @@ class CommentTest extends TestCase
$this->asAdmin();
$page = Page::first();
$comment = factory(Comment::class)->make(['parent_id' => 2]);
$comment = Comment::factory()->make(['parent_id' => 2]);
$resp = $this->postJson("/comment/$page->id", $comment->getAttributes());
$resp->assertStatus(200);
@@ -36,7 +36,7 @@ class CommentTest extends TestCase
$this->asAdmin();
$page = Page::first();
$comment = factory(Comment::class)->make();
$comment = Comment::factory()->make();
$this->postJson("/comment/$page->id", $comment->getAttributes());
$comment = $page->comments()->first();
@@ -60,7 +60,7 @@ class CommentTest extends TestCase
$this->asAdmin();
$page = Page::first();
$comment = factory(Comment::class)->make();
$comment = Comment::factory()->make();
$this->postJson("/comment/$page->id", $comment->getAttributes());
$comment = $page->comments()->first();

View File

@@ -20,7 +20,7 @@ class PageDraftTest extends TestCase
*/
protected $pageRepo;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->page = Page::query()->first();

View File

@@ -11,7 +11,7 @@ class PageEditorTest extends TestCase
/** @var Page */
protected $page;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->page = Page::query()->first();

View File

@@ -14,7 +14,7 @@ class PageTest extends TestCase
{
/** @var Chapter $chapter */
$chapter = Chapter::query()->first();
$page = factory(Page::class)->make([
$page = Page::factory()->make([
'name' => 'My First Page',
]);

View File

@@ -12,7 +12,7 @@ class SortTest extends TestCase
{
protected $book;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->book = Book::first();

View File

@@ -19,7 +19,7 @@ class TagTest extends TestCase
$entity = $class::first();
if (is_null($tags)) {
$tags = factory(Tag::class, $this->defaultTagCount)->make();
$tags = Tag::factory()->count($this->defaultTagCount)->make();
}
$entity->tags()->saveMany($tags);
@@ -31,63 +31,63 @@ class TagTest extends TestCase
{
// Create some tags with similar names to test with
$attrs = collect();
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'country']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'color']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'city']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'county']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'planet']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'plans']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'country']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'color']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'city']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'county']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'planet']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'plans']));
$page = $this->getEntityWithTags(Page::class, $attrs->all());
$this->asAdmin()->get('/ajax/tags/suggest/names?search=dog')->assertExactJson([]);
$this->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country', 'county']);
$this->get('/ajax/tags/suggest/names?search=cou')->assertExactJson(['country', 'county']);
$this->get('/ajax/tags/suggest/names?search=pla')->assertExactJson(['planet', 'plans']);
$this->asAdmin()->get('/ajax/tags/suggest/names?search=dog')->assertSimilarJson([]);
$this->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country', 'county']);
$this->get('/ajax/tags/suggest/names?search=cou')->assertSimilarJson(['country', 'county']);
$this->get('/ajax/tags/suggest/names?search=pla')->assertSimilarJson(['planet', 'plans']);
}
public function test_tag_value_suggestions()
{
// Create some tags with similar values to test with
$attrs = collect();
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'country', 'value' => 'cats']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'color', 'value' => 'cattery']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'city', 'value' => 'castle']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'county', 'value' => 'dog']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'planet', 'value' => 'catapult']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'plans', 'value' => 'dodgy']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'country', 'value' => 'cats']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'color', 'value' => 'cattery']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'city', 'value' => 'castle']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'county', 'value' => 'dog']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'planet', 'value' => 'catapult']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'plans', 'value' => 'dodgy']));
$page = $this->getEntityWithTags(Page::class, $attrs->all());
$this->asAdmin()->get('/ajax/tags/suggest/values?search=ora')->assertExactJson([]);
$this->get('/ajax/tags/suggest/values?search=cat')->assertExactJson(['cats', 'cattery', 'catapult']);
$this->get('/ajax/tags/suggest/values?search=do')->assertExactJson(['dog', 'dodgy']);
$this->get('/ajax/tags/suggest/values?search=cas')->assertExactJson(['castle']);
$this->asAdmin()->get('/ajax/tags/suggest/values?search=ora')->assertSimilarJson([]);
$this->get('/ajax/tags/suggest/values?search=cat')->assertSimilarJson(['cats', 'cattery', 'catapult']);
$this->get('/ajax/tags/suggest/values?search=do')->assertSimilarJson(['dog', 'dodgy']);
$this->get('/ajax/tags/suggest/values?search=cas')->assertSimilarJson(['castle']);
}
public function test_entity_permissions_effect_tag_suggestions()
{
// Create some tags with similar names to test with and save to a page
$attrs = collect();
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'country']));
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'color']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'country']));
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'color']));
$page = $this->getEntityWithTags(Page::class, $attrs->all());
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country']);
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country']);
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
// Set restricted permission the page
$page->restricted = true;
$page->save();
$page->rebuildPermissions();
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country']);
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertExactJson([]);
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson([]);
}
public function test_tags_shown_on_search_listing()
{
$tags = [
factory(Tag::class)->make(['name' => 'category', 'value' => 'buckets']),
factory(Tag::class)->make(['name' => 'color', 'value' => 'red']),
Tag::factory()->make(['name' => 'category', 'value' => 'buckets']),
Tag::factory()->make(['name' => 'color', 'value' => 'red']),
];
$page = $this->getEntityWithTags(Page::class, $tags);

View File

@@ -167,7 +167,7 @@ class HomepageTest extends TestCase
public function test_new_users_dont_have_any_recently_viewed()
{
$user = factory(User::class)->create();
$user = User::factory()->create();
$viewRole = Role::getRole('Viewer');
$user->attachRole($viewRole);

View File

@@ -9,7 +9,7 @@ class LanguageTest extends TestCase
/**
* LanguageTest constructor.
*/
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']);

View File

@@ -23,7 +23,7 @@ class EntityPermissionsTest extends TestCase
*/
protected $viewer;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->user = $this->getEditor();

View File

@@ -19,7 +19,7 @@ class RolesTest extends TestCase
{
protected $user;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->user = $this->getViewer();
@@ -769,7 +769,7 @@ class RolesTest extends TestCase
$this->giveUserPermissions($this->user, ['image-update-all']);
/** @var Page $page */
$page = Page::query()->first();
$image = factory(Image::class)->create([
$image = Image::factory()->create([
'uploaded_to' => $page->id,
'created_by' => $this->user->id,
'updated_by' => $this->user->id,
@@ -789,7 +789,7 @@ class RolesTest extends TestCase
$admin = $this->getAdmin();
/** @var Page $page */
$page = Page::query()->first();
$image = factory(Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
$image = Image::factory()->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
@@ -825,14 +825,14 @@ class RolesTest extends TestCase
{
$admin = $this->getAdmin();
// Book links
$book = factory(Book::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
$book = Book::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
$this->regenEntityPermissions($book);
$this->actingAs($this->getViewer())->get($book->getUrl())
->assertDontSee('Create a new page')
->assertDontSee('Add a chapter');
// Chapter links
$chapter = factory(Chapter::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
$chapter = Chapter::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
$this->regenEntityPermissions($chapter);
$this->actingAs($this->getViewer())->get($chapter->getUrl())
->assertDontSee('Create a new page')
@@ -926,14 +926,14 @@ class RolesTest extends TestCase
private function addComment(Page $page): TestResponse
{
$comment = factory(Comment::class)->make();
$comment = Comment::factory()->make();
return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
}
private function updateComment(Comment $comment): TestResponse
{
$commentData = factory(Comment::class)->make();
$commentData = Comment::factory()->make();
return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
}

View File

@@ -210,7 +210,7 @@ trait SharedTestHelpers
protected function createNewRole(array $permissions = []): Role
{
$permissionRepo = app(PermissionsRepo::class);
$roleData = factory(Role::class)->make()->toArray();
$roleData = Role::factory()->make()->toArray();
$roleData['permissions'] = array_flip($permissions);
return $permissionRepo->saveNewRole($roleData);
@@ -228,9 +228,9 @@ trait SharedTestHelpers
}
$userAttrs = ['created_by' => $creatorUser->id, 'owned_by' => $creatorUser->id, 'updated_by' => $updaterUser->id];
$book = factory(Book::class)->create($userAttrs);
$chapter = factory(Chapter::class)->create(array_merge(['book_id' => $book->id], $userAttrs));
$page = factory(Page::class)->create(array_merge(['book_id' => $book->id, 'chapter_id' => $chapter->id], $userAttrs));
$book = Book::factory()->create($userAttrs);
$chapter = Chapter::factory()->create(array_merge(['book_id' => $book->id], $userAttrs));
$page = Page::factory()->create(array_merge(['book_id' => $book->id, 'chapter_id' => $chapter->id], $userAttrs));
$restrictionService = $this->app[PermissionService::class];
$restrictionService->buildJointPermissionsForEntity($book);

View File

@@ -150,7 +150,7 @@ class ThemeTest extends TestCase
Theme::listen(ThemeEvents::AUTH_REGISTER, $callback);
$this->setSettings(['registration-enabled' => 'true']);
$user = factory(User::class)->make();
$user = User::factory()->make();
$this->post('/register', ['email' => $user->email, 'name' => $user->name, 'password' => 'password']);
$this->assertCount(2, $args);

View File

@@ -42,7 +42,7 @@ class AvatarTest extends TestCase
config()->set([
'services.disable_services' => false,
]);
$user = factory(User::class)->make();
$user = User::factory()->make();
$this->assertImageFetchFrom('https://www.gravatar.com/avatar/' . md5(strtolower($user->email)) . '?s=500&d=identicon');
$user = $this->createUserRequest($user);
@@ -60,7 +60,7 @@ class AvatarTest extends TestCase
'services.avatar_url' => 'https://example.com/${email}/${hash}/${size}',
]);
$user = factory(User::class)->make();
$user = User::factory()->make();
$url = 'https://example.com/' . urlencode(strtolower($user->email)) . '/' . md5(strtolower($user->email)) . '/500';
$this->assertImageFetchFrom($url);
@@ -74,7 +74,7 @@ class AvatarTest extends TestCase
'services.disable_services' => true,
]);
$user = factory(User::class)->make();
$user = User::factory()->make();
$http = $this->mock(HttpFetcher::class);
$http->shouldNotReceive('fetch');
@@ -93,7 +93,7 @@ class AvatarTest extends TestCase
$logger = $this->withTestLogger();
$user = factory(User::class)->make();
$user = User::factory()->make();
$this->createUserRequest($user);
$this->assertTrue($logger->hasError('Failed to save user avatar image'));
}

View File

@@ -15,7 +15,7 @@ class UserManagementTest extends TestCase
public function test_user_creation()
{
/** @var User $user */
$user = factory(User::class)->make();
$user = User::factory()->make();
$adminRole = Role::getRole('admin');
$resp = $this->asAdmin()->get('/settings/users');

View File

@@ -14,7 +14,7 @@ class UserProfileTest extends TestCase
*/
protected $user;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->user = User::all()->last();
@@ -42,7 +42,7 @@ class UserProfileTest extends TestCase
public function test_profile_page_shows_created_content_counts()
{
$newUser = factory(User::class)->create();
$newUser = User::factory()->create();
$this->asAdmin()->get('/user/' . $newUser->slug)
->assertSee($newUser->name)
@@ -61,7 +61,7 @@ class UserProfileTest extends TestCase
public function test_profile_page_shows_recent_activity()
{
$newUser = factory(User::class)->create();
$newUser = User::factory()->create();
$this->actingAs($newUser);
$entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
@@ -75,7 +75,7 @@ class UserProfileTest extends TestCase
public function test_user_activity_has_link_leading_to_profile()
{
$newUser = factory(User::class)->create();
$newUser = User::factory()->create();
$this->actingAs($newUser);
$entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);