[TESTS][Forms] Respect new naming conventions

This commit is contained in:
Diogo Peralta Cordeiro 2021-08-19 01:09:42 +01:00 committed by Hugo Sales
parent 9067bd8785
commit aa8412f607
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 25 additions and 25 deletions

View File

@ -38,15 +38,15 @@ class AdminTest extends GNUsocialTestCase
$value = $get_value(); $value = $get_value();
$client->request('GET', '/panel'); $client->request('GET', '/panel');
$crawler = $client->submitForm('Set site setting', [ $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 // 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)); static::assertSame($value, Common::config(...$setting));
// $client->request('GET', '/panel'); // $client->request('GET', '/panel');
$crawler = $client->submitForm('Set site setting', [ $crawler = $client->submitForm('Set site setting', [
'save[setting]' => implode(':', $setting), 'save_admin[setting]' => implode(':', $setting),
'save[value]' => Formatting::toString($old), 'save_admin[value]' => Formatting::toString($old),
]); ]);
static::assertSame($old, Common::config(...$setting)); static::assertSame($old, Common::config(...$setting));
rename(INSTALLDIR . '/social.local.yaml.back', INSTALLDIR . '/social.local.yaml'); rename(INSTALLDIR . '/social.local.yaml.back', INSTALLDIR . '/social.local.yaml');
@ -83,8 +83,8 @@ class AdminTest extends GNUsocialTestCase
$client->request('GET', '/panel'); $client->request('GET', '/panel');
$this->assertThrows(\InvalidArgumentException::class, $this->assertThrows(\InvalidArgumentException::class,
fn () => $client->submitForm('Set site setting', [ fn () => $client->submitForm('Set site setting', [
'save[setting]' => 'invalid:section', 'save_admin[setting]' => 'invalid:section',
'save[value]' => 'false', 'save_admin[value]' => 'false',
])); ]));
} }
} }

View File

@ -43,12 +43,12 @@ class UserPanelTest extends GNUsocialTestCase
$client->request('GET', '/settings'); $client->request('GET', '/settings');
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$crawler = $client->submitForm('Save personal info', [ $crawler = $client->submitForm('Save personal info', [
'save[nickname]' => 'form_test_user_new_nickname', 'save_personal_info[nickname]' => 'form_test_user_new_nickname',
'save[full_name]' => 'Form User', 'save_personal_info[full_name]' => 'Form User',
'save[homepage]' => 'https://gnu.org', 'save_personal_info[homepage]' => 'https://gnu.org',
'save[bio]' => 'I was born at a very young age', 'save_personal_info[bio]' => 'I was born at a very young age',
'save[location]' => 'right here', 'save_personal_info[location]' => 'right here',
'save[self_tags]' => 'foo bar', 'save_personal_info[self_tags]' => 'foo bar',
]); ]);
$changed_user = DB::findOneBy('local_user', ['id' => $user->getId()]); $changed_user = DB::findOneBy('local_user', ['id' => $user->getId()]);
$actor = $changed_user->getActor(); $actor = $changed_user->getActor();
@ -76,13 +76,13 @@ class UserPanelTest extends GNUsocialTestCase
$client->request('GET', '/settings'); $client->request('GET', '/settings');
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$crawler = $client->submitForm('Save account info', [ $crawler = $client->submitForm('Save account info', [
'save[outgoing_email]' => 'outgoing@provider', 'save_account_info[outgoing_email]' => 'outgoing@provider',
'save[incoming_email]' => 'incoming@provider', 'save_account_info[incoming_email]' => 'incoming@provider',
'save[old_password]' => 'some password', 'save_account_info[old_password]' => 'some password',
'save[password][first]' => 'this is some test password', 'save_account_info[password][first]' => 'this is some test password',
'save[password][second]' => 'this is some test password', 'save_account_info[password][second]' => 'this is some test password',
'save[language]' => 'pt', 'save_account_info[language]' => 'pt',
'save[phone_number]' => '+351908555842', // from fakenumber.net 'save_account_info[phone_number]' => '+351908555842', // from fakenumber.net
]); ]);
$changed_user = DB::findOneBy('local_user', ['id' => $user->getId()]); $changed_user = DB::findOneBy('local_user', ['id' => $user->getId()]);
@ -106,9 +106,9 @@ class UserPanelTest extends GNUsocialTestCase
$client->request('GET', '/settings'); $client->request('GET', '/settings');
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$crawler = $client->submitForm('Save account info', [ $crawler = $client->submitForm('Save account info', [
'save[old_password]' => 'some wrong password', 'save_account_info[old_password]' => 'some wrong password',
'save[password][first]' => 'this is some test password', 'save_account_info[password][first]' => 'this is some test password',
'save[password][second]' => 'this is some test password', 'save_account_info[password][second]' => 'this is some test password',
]); ]);
$this->assertResponseStatusCodeSame(500); // 401 in future $this->assertResponseStatusCodeSame(500); // 401 in future
$this->assertSelectorTextContains('.stacktrace', 'AuthenticationException'); $this->assertSelectorTextContains('.stacktrace', 'AuthenticationException');

View File

@ -39,11 +39,11 @@ class FormTest extends GNUsocialTestCase
$form = Form::create($form_array = [ $form = Form::create($form_array = [
['content', TextareaType::class, ['label' => ' ', 'data' => '', 'attr' => ['placeholder' => 'placeholder']]], ['content', TextareaType::class, ['label' => ' ', 'data' => '', 'attr' => ['placeholder' => 'placeholder']]],
['array_trans', TextareaType::class, ['data' => ['foo', 'bar'], 'transformer' => ArrayTransformer::class]], ['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'); static::assertSame(get_class($form), 'Symfony\\Component\\Form\\Form');
foreach ($form as $name => $f) { foreach ($form as $name => $f) {
if ($name == 'post') { if ($name == 'testpost') {
static::assertSame(get_class($f), 'Symfony\Component\Form\SubmitButton'); static::assertSame(get_class($f), 'Symfony\Component\Form\SubmitButton');
} else { } else {
static::assertSame(get_class($f), 'Symfony\Component\Form\Form'); static::assertSame(get_class($f), 'Symfony\Component\Form\Form');
@ -84,7 +84,7 @@ class FormTest extends GNUsocialTestCase
$form = Form::create([ $form = Form::create([
['nickname', TextareaType::class, []], ['nickname', TextareaType::class, []],
['normalized_nickname', TextareaType::class, []], ['normalized_nickname', TextareaType::class, []],
['post', SubmitType::class, []], ['testpost', SubmitType::class, []],
], target: $user); ], target: $user);
$options = $form['nickname']->getConfig()->getOptions(); $options = $form['nickname']->getConfig()->getOptions();
static::assertSame($nick, $options['data']); static::assertSame($nick, $options['data']);