-
Notifications
You must be signed in to change notification settings - Fork 42
Additional form builder optimizations #3530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,53 @@ | |
| #[\PHPUnit\Framework\Attributes\CoversClass( FrmFieldsController::class )] | ||
| class test_FrmFieldsController extends FrmUnitTest { | ||
|
|
||
| public function test_builder_batches_omit_only_received_definitions() { | ||
| $definitions = array( | ||
| 'known' => array( 'value' => 'Saved option' ), | ||
| 'new' => array( 'value' => 'New option' ), | ||
| ); | ||
| $_POST['known_select_options'] = 'known,unknown,known'; | ||
| $_POST['known_tooltips'] = 'new'; | ||
|
|
||
| try { | ||
| $this->assertSame( | ||
| array( 'new' => $definitions['new'] ), | ||
| $this->run_private_method( array( 'FrmFieldsController', 'get_missing_builder_definitions' ), array( $definitions, 'known_select_options' ) ) | ||
| ); | ||
| $this->assertSame( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| array( 'known' => $definitions['known'] ), | ||
| $this->run_private_method( array( 'FrmFieldsController', 'get_missing_builder_definitions' ), array( $definitions, 'known_tooltips' ) ) | ||
| ); | ||
| } finally { | ||
| unset( $_POST['known_select_options'], $_POST['known_tooltips'] ); | ||
| } | ||
| } | ||
|
|
||
| public function test_builder_batches_keep_definitions_for_older_or_malformed_requests() { | ||
| $definitions = array( 'known' => 'Tooltip text' ); | ||
| unset( $_POST['known_tooltips'] ); | ||
|
|
||
| try { | ||
| foreach ( array( null, '', array( 'known' ) ) as $known_keys ) { | ||
| if ( null !== $known_keys ) { | ||
| $_POST['known_tooltips'] = $known_keys; | ||
| } | ||
| $this->assertSame( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| $definitions, | ||
| $this->run_private_method( array( 'FrmFieldsController', 'get_missing_builder_definitions' ), array( $definitions, 'known_tooltips' ) ) | ||
| ); | ||
| } | ||
|
|
||
| $_POST['known_tooltips'] = 'known'; | ||
| $this->assertSame( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| array(), | ||
| $this->run_private_method( array( 'FrmFieldsController', 'get_missing_builder_definitions' ), array( $definitions, 'known_tooltips' ) ) | ||
| ); | ||
| } finally { | ||
| unset( $_POST['known_tooltips'] ); | ||
| } | ||
| } | ||
|
|
||
| public function test_prepare_placeholder() { | ||
| $name = 'Number'; | ||
| $field = array( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method you are trying to call is not defined, which can result in a fatal error.