From aa8412f607ad8607824192ded6d2bc4b6eb86c28 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Thu, 19 Aug 2021 01:09:42 +0100 Subject: [PATCH] [TESTS][Forms] Respect new naming conventions --- tests/Controller/AdminTest.php | 12 +++++------ tests/Controller/UserPanelTest.php | 32 +++++++++++++++--------------- tests/Core/FormTest.php | 6 +++--- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/Controller/AdminTest.php b/tests/Controller/AdminTest.php index b3bd811818..75557f40c9 100644 --- a/tests/Controller/AdminTest.php +++ b/tests/Controller/AdminTest.php @@ -38,15 +38,15 @@ class AdminTest extends GNUsocialTestCase $value = $get_value(); $client->request('GET', '/panel'); $crawler = $client->submitForm('Set site setting', [ - 'save[setting]' => implode(':', $setting), + 'save_admin[setting]' => implode(':', $setting), // False gets converted to "", which HTTP doesn't send, so we get null on the other side - 'save[value]' => $value == false ? 'fAlse' : Formatting::toString($value), + 'save_admin[value]' => $value == false ? 'false' : Formatting::toString($value), ]); static::assertSame($value, Common::config(...$setting)); // $client->request('GET', '/panel'); $crawler = $client->submitForm('Set site setting', [ - 'save[setting]' => implode(':', $setting), - 'save[value]' => Formatting::toString($old), + 'save_admin[setting]' => implode(':', $setting), + 'save_admin[value]' => Formatting::toString($old), ]); static::assertSame($old, Common::config(...$setting)); rename(INSTALLDIR . '/social.local.yaml.back', INSTALLDIR . '/social.local.yaml'); @@ -83,8 +83,8 @@ class AdminTest extends GNUsocialTestCase $client->request('GET', '/panel'); $this->assertThrows(\InvalidArgumentException::class, fn () => $client->submitForm('Set site setting', [ - 'save[setting]' => 'invalid:section', - 'save[value]' => 'false', + 'save_admin[setting]' => 'invalid:section', + 'save_admin[value]' => 'false', ])); } } diff --git a/tests/Controller/UserPanelTest.php b/tests/Controller/UserPanelTest.php index a20c2674cb..e8169df86a 100644 --- a/tests/Controller/UserPanelTest.php +++ b/tests/Controller/UserPanelTest.php @@ -43,12 +43,12 @@ class UserPanelTest extends GNUsocialTestCase $client->request('GET', '/settings'); $this->assertResponseIsSuccessful(); $crawler = $client->submitForm('Save personal info', [ - 'save[nickname]' => 'form_test_user_new_nickname', - 'save[full_name]' => 'Form User', - 'save[homepage]' => 'https://gnu.org', - 'save[bio]' => 'I was born at a very young age', - 'save[location]' => 'right here', - 'save[self_tags]' => 'foo bar', + 'save_personal_info[nickname]' => 'form_test_user_new_nickname', + 'save_personal_info[full_name]' => 'Form User', + 'save_personal_info[homepage]' => 'https://gnu.org', + 'save_personal_info[bio]' => 'I was born at a very young age', + 'save_personal_info[location]' => 'right here', + 'save_personal_info[self_tags]' => 'foo bar', ]); $changed_user = DB::findOneBy('local_user', ['id' => $user->getId()]); $actor = $changed_user->getActor(); @@ -76,13 +76,13 @@ class UserPanelTest extends GNUsocialTestCase $client->request('GET', '/settings'); $this->assertResponseIsSuccessful(); $crawler = $client->submitForm('Save account info', [ - 'save[outgoing_email]' => 'outgoing@provider', - 'save[incoming_email]' => 'incoming@provider', - 'save[old_password]' => 'some password', - 'save[password][first]' => 'this is some test password', - 'save[password][second]' => 'this is some test password', - 'save[language]' => 'pt', - 'save[phone_number]' => '+351908555842', // from fakenumber.net + 'save_account_info[outgoing_email]' => 'outgoing@provider', + 'save_account_info[incoming_email]' => 'incoming@provider', + 'save_account_info[old_password]' => 'some password', + 'save_account_info[password][first]' => 'this is some test password', + 'save_account_info[password][second]' => 'this is some test password', + 'save_account_info[language]' => 'pt', + 'save_account_info[phone_number]' => '+351908555842', // from fakenumber.net ]); $changed_user = DB::findOneBy('local_user', ['id' => $user->getId()]); @@ -106,9 +106,9 @@ class UserPanelTest extends GNUsocialTestCase $client->request('GET', '/settings'); $this->assertResponseIsSuccessful(); $crawler = $client->submitForm('Save account info', [ - 'save[old_password]' => 'some wrong password', - 'save[password][first]' => 'this is some test password', - 'save[password][second]' => 'this is some test password', + 'save_account_info[old_password]' => 'some wrong password', + 'save_account_info[password][first]' => 'this is some test password', + 'save_account_info[password][second]' => 'this is some test password', ]); $this->assertResponseStatusCodeSame(500); // 401 in future $this->assertSelectorTextContains('.stacktrace', 'AuthenticationException'); diff --git a/tests/Core/FormTest.php b/tests/Core/FormTest.php index dc92fa86b7..938a6bf2dd 100644 --- a/tests/Core/FormTest.php +++ b/tests/Core/FormTest.php @@ -39,11 +39,11 @@ class FormTest extends GNUsocialTestCase $form = Form::create($form_array = [ ['content', TextareaType::class, ['label' => ' ', 'data' => '', 'attr' => ['placeholder' => 'placeholder']]], ['array_trans', TextareaType::class, ['data' => ['foo', 'bar'], 'transformer' => ArrayTransformer::class]], - ['post', SubmitType::class, ['label' => 'Post']], + ['testpost', SubmitType::class, ['label' => 'Post']], ]); static::assertSame(get_class($form), 'Symfony\\Component\\Form\\Form'); foreach ($form as $name => $f) { - if ($name == 'post') { + if ($name == 'testpost') { static::assertSame(get_class($f), 'Symfony\Component\Form\SubmitButton'); } else { static::assertSame(get_class($f), 'Symfony\Component\Form\Form'); @@ -84,7 +84,7 @@ class FormTest extends GNUsocialTestCase $form = Form::create([ ['nickname', TextareaType::class, []], ['normalized_nickname', TextareaType::class, []], - ['post', SubmitType::class, []], + ['testpost', SubmitType::class, []], ], target: $user); $options = $form['nickname']->getConfig()->getOptions(); static::assertSame($nick, $options['data']);