[TESTS] Fix tests by adding missing is_local columns and by login in the admin user in the admin panel test
This commit is contained in:
parent
d9544c6edb
commit
0194b6b14c
@ -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());
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user