-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Safeguard array in WP_Job_Manager_Settings::input_capabilities (#2631)
* Safeguard array in WP_Job_Manager_Settings::input_capabilities * Update PHPUnit polyfills deps in composer.json/lock
- Loading branch information
Showing
5 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/php/includes/stubs/class-wp-job-manager-admin-settings-stub.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class WP_Job_Manager_Admin_Settings_Stub extends WP_Job_Manager_Settings { | ||
private static $instance = null; | ||
|
||
public static function instance() { | ||
if ( is_null( self::$instance ) ) { | ||
self::$instance = new self(); | ||
} | ||
return self::$instance; | ||
} | ||
|
||
public function test_input_capabilities( $option, $attributes, $value ) { | ||
return $this->input_capabilities( $option, $attributes, $value, '' ); | ||
} | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
tests/php/tests/includes/admin/test_class.wp-job-manager-settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
require_once JOB_MANAGER_PLUGIN_DIR . '/includes/admin/class-wp-job-manager-settings.php'; | ||
require_once WPJM_Unit_Tests_Bootstrap::instance()->includes_dir . '/stubs/class-wp-job-manager-admin-settings-stub.php'; | ||
|
||
class WP_Test_WP_Job_Manager_Settings extends WPJM_BaseTest { | ||
|
||
public function test_input_capabilities_should_not_fail_on_invalid_capabilities_provided() { | ||
$stub = WP_Job_Manager_Admin_Settings_Stub::instance(); | ||
|
||
$values_to_test = array( | ||
null, | ||
0, | ||
'', | ||
'invalid', | ||
array(), | ||
new stdClass(), | ||
); | ||
|
||
$this->setOutputCallback( function() {} ); | ||
$this->expectNotToPerformAssertions(); | ||
|
||
foreach ( $values_to_test as $value ) { | ||
$stub->test_input_capabilities( [ 'name' => 'test' ], [], $value ); | ||
} | ||
} | ||
|
||
} |