diff --git a/src/DataFixtures/CoreFixtures.php b/src/DataFixtures/CoreFixtures.php index 0848ecc4af..cf622bde0a 100644 --- a/src/DataFixtures/CoreFixtures.php +++ b/src/DataFixtures/CoreFixtures.php @@ -4,6 +4,7 @@ declare(strict_types = 1); namespace App\DataFixtures; +use App\Core\UserRoles; use App\Core\VisibilityScope; use App\Entity\Actor; use App\Entity\GroupInbox; @@ -22,14 +23,15 @@ class CoreFixtures extends Fixture $actors = []; $local_entities = []; foreach ([ - 'taken_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('foobar'), 'outgoing_email' => 'email@provider']], - 'some_user' => [LocalUser::class, 'setId', []], - 'local_user_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('foobar')]], - 'form_personal_info_test_user' => [LocalUser::class, 'setId', []], - 'form_account_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('some password')]], - 'taken_group' => [LocalGroup::class, 'setGroupId', []], - ] as $nick => [$entity, $method, $extra_create]) { - $actor = Actor::create(['nickname' => $nick, 'is_local' => true]); + 'taken_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('foobar'), 'outgoing_email' => 'email@provider'], []], + 'some_user' => [LocalUser::class, 'setId', [], []], + 'admin' => [LocalUser::class, 'setId', [], ['roles' => UserRoles::ADMIN | UserRoles::USER]], + 'local_user_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('foobar')], []], + 'form_personal_info_test_user' => [LocalUser::class, 'setId', [], []], + 'form_account_test_user' => [LocalUser::class, 'setId', ['password' => LocalUser::hashPassword('some password')], []], + 'taken_group' => [LocalGroup::class, 'setGroupId', [], []], + ] as $nick => [$entity, $method, $extra_create, $extra_create_actor]) { + $actor = Actor::create(array_merge(['nickname' => $nick, 'is_local' => true], $extra_create_actor)); $manager->persist($actor); $ent = $entity::create(array_merge(['nickname' => $nick], $extra_create)); // cannot use array spread for arrays with string keys $ent->{$method}($actor->getId()); diff --git a/tests/Controller/AdminTest.php b/tests/Controller/AdminTest.php index 39d9e2d040..5d5febff4f 100644 --- a/tests/Controller/AdminTest.php +++ b/tests/Controller/AdminTest.php @@ -21,8 +21,9 @@ declare(strict_types = 1); // }}} -namespace App\Tests\Core; +namespace App\Tests\Controller; +use App\Core\DB\DB; use App\Util\Common; use App\Util\Formatting; use App\Util\GNUsocialTestCase; @@ -36,6 +37,7 @@ class AdminTest extends GNUsocialTestCase private function test(array $setting, callable $get_value) { $client = static::createClient(); + $client->loginUser(DB::findOneBy('local_user', ['nickname' => 'admin'])); copy(INSTALLDIR . '/social.local.yaml', INSTALLDIR . '/social.local.yaml.back'); $old = Common::config(...$setting); $value = $get_value(); diff --git a/tests/Controller/SecurityTest.php b/tests/Controller/SecurityTest.php index d48dbdb069..813318c1cd 100644 --- a/tests/Controller/SecurityTest.php +++ b/tests/Controller/SecurityTest.php @@ -37,8 +37,8 @@ class SecurityTest extends GNUsocialTestCase $this->assertResponseIsSuccessful(); // $form = $crawler->selectButton('Sign in')->form(); $crawler = $client->submitForm('Sign in', [ - 'nickname_or_email' => $nickname, - 'password' => $password, + '_username' => $nickname, + '_password' => $password, ]); $this->assertResponseStatusCodeSame(302); $crawler = $client->followRedirect(); diff --git a/tests/Core/DB/DBTest.php b/tests/Core/DB/DBTest.php index f439268aa5..f40d575efd 100644 --- a/tests/Core/DB/DBTest.php +++ b/tests/Core/DB/DBTest.php @@ -80,7 +80,7 @@ class DBTest extends GNUsocialTestCase public function testPersistWithSameId() { - $actor = Actor::create(['nickname' => 'test', 'bio' => 'some very interesting bio']); + $actor = Actor::create(['nickname' => 'test', 'bio' => 'some very interesting bio', 'is_local' => false]); $user = LocalUser::create(['nickname' => 'test']); $id = DB::persistWithSameId($actor, $user, fn ($id) => $id); static::assertTrue($id != 0); diff --git a/tests/Core/FormTest.php b/tests/Core/FormTest.php index b482589433..9e72632640 100644 --- a/tests/Core/FormTest.php +++ b/tests/Core/FormTest.php @@ -118,7 +118,7 @@ class FormTest extends GNUsocialTestCase $ret = Form::handle(form_definition: [/* not normal usage */], request: $mock_request, target: null, extra_args: [], extra_step: null, create_args: [], testing_only_form: $mock_form); static::assertSame($data, $ret); - $actor = Actor::create(['nickname' => 'form_testing_new_user']); + $actor = Actor::create(['nickname' => 'form_testing_new_user', 'is_local' => false]); DB::persist($actor); $ret = Form::handle(form_definition: [/* not normal usage */], request: $mock_request, target: $actor, extra_args: [], extra_step: null, create_args: [], testing_only_form: $mock_form); static::assertSame($mock_form, $ret); diff --git a/tests/Entity/AttachmentTest.php b/tests/Entity/AttachmentTest.php index a95514c794..9f1a2ea3b6 100644 --- a/tests/Entity/AttachmentTest.php +++ b/tests/Entity/AttachmentTest.php @@ -106,7 +106,7 @@ class AttachmentTest extends GNUsocialTestCase $attachment->setFilename($filename); $actor = DB::findOneBy('actor', ['nickname' => 'taken_user']); - DB::persist($note = Note::create(['actor_id' => $actor->getId(), 'content' => 'attachment: some content', 'content_type' => 'text/plain'])); + DB::persist($note = Note::create(['actor_id' => $actor->getId(), 'content' => 'attachment: some content', 'content_type' => 'text/plain', 'is_local' => true])); DB::persist(AttachmentToNote::create(['attachment_id' => $attachment->getId(), 'note_id' => $note->getId(), 'title' => 'A title'])); DB::flush();