Skip to content

Commit

Permalink
Updated array syntax for Actions API tests (PR Getbeans#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofromtonya authored Jun 21, 2018
2 parents bec77a7 + 1254d34 commit dc7fe4f
Show file tree
Hide file tree
Showing 38 changed files with 269 additions and 269 deletions.
12 changes: 6 additions & 6 deletions tests/phpunit/integration/api/actions/beansAddAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public function test_should_overwrite_add_action_in_beans_and_wordpress() {
* Test beans_add_action() should use the action configuration in "replaced" status, when it's available.
*/
public function test_should_use_replaced_action_when_available() {
$replaced_action = array(
$replaced_action = [
'callback' => 'my_new_callback',
'priority' => 47,
);
];

foreach ( static::$test_actions as $beans_id => $original_action ) {
// We want to store the "replaced" action first, before we add the original action.
Expand All @@ -96,12 +96,12 @@ public function test_should_use_replaced_action_when_available() {
* Test beans_add_action() should return false when the ID is registered to the "removed" status.
*/
public function test_should_return_false_when_removed() {
$empty_action = array(
$empty_action = [
'hook' => null,
'callback' => null,
'priority' => null,
'args' => null,
);
];

foreach ( static::$test_actions as $beans_id => $action ) {
// Store the "removed" action before we call beans_add_action().
Expand All @@ -122,10 +122,10 @@ public function test_should_return_false_when_removed() {
* Test beans_add_action() should merge the "modified" action configuration parameters.
*/
public function test_should_merge_modified_action_parameters() {
$modified_action = array(
$modified_action = [
'callback' => 'foo',
'priority' => 17,
);
];

foreach ( static::$test_actions as $beans_id => $original_action ) {
// We want to store the "modified" action first, before we add the original action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Tests_BeansAddAnonymousAction extends WP_UnitTestCase {
* Test _beans_add_anonymous_action() should register callback to the given hook.
*/
public function test_should_register_callback_to_hook() {
_beans_add_anonymous_action( 'do_foo', array( 'foo_test_callback', array( 'foo' ) ) );
_beans_add_anonymous_action( 'do_foo', [ 'foo_test_callback', [ 'foo' ] ] );

$this->assertTrue( has_action( 'do_foo' ) );
}
Expand All @@ -34,7 +34,7 @@ public function test_should_register_callback_to_hook() {
* Test _beans_add_anonymous_action() should call callback on the given hook.
*/
public function test_should_call_callback() {
_beans_add_anonymous_action( 'beans_test_do_foo', array( 'foo_test_callback', array( 'foo' ) ) );
_beans_add_anonymous_action( 'beans_test_do_foo', [ 'foo_test_callback', [ 'foo' ] ] );

Functions\when( 'foo_test_callback' )
->justReturn( 'foo' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public function test_should_return_false_when_modified_but_no_added_action() {
public function test_should_return_merged_added_and_modified_action() {
global $_beans_registered_actions;

$modified_action = array(
$modified_action = [
'callback' => 'callback',
'priority' => 27,
'args' => 14,
);
];

foreach ( static::$test_actions as $beans_id => $action ) {
// Store the action in the registry.
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/integration/api/actions/beansMergeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class Tests_BeansMergeAction extends Actions_Test_Case {
*
* @var array
*/
protected $statuses = array( 'added', 'modified', 'removed', 'replaced' );
protected $statuses = [ 'added', 'modified', 'removed', 'replaced' ];

/**
* Test _beans_set_action() should merge the new action's configuration with the registered one and then return it.
*/
public function test_should_merge_and_return() {
global $_beans_registered_actions;

$modified_action = array(
$modified_action = [
'priority' => 29,
);
];

foreach ( static::$test_actions as $beans_id => $action ) {
$merged_action = array_merge( $action, $modified_action );
Expand Down
24 changes: 12 additions & 12 deletions tests/phpunit/integration/api/actions/beansModifyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function test_should_register_as_modified_but_not_add_action() {
* Test beans_modify_action() should modify the registered action's hook.
*/
public function test_should_modify_the_action_hook() {
$modified_action = array(
$modified_action = [
'hook' => 'foo',
);
];

$this->go_to_post();

Expand All @@ -97,9 +97,9 @@ public function test_should_modify_the_action_hook() {
* Test beans_modify_action() should modify the registered action's callback.
*/
public function test_should_modify_the_action_callback() {
$modified_action = array(
$modified_action = [
'callback' => 'my_callback',
);
];

$this->go_to_post();

Expand Down Expand Up @@ -128,19 +128,19 @@ public function test_should_modify_the_action_callback() {
public function test_should_modify_the_action_priority() {
global $wp_filter;

$modified_action = array(
$modified_action = [
'priority' => 20,
);
];

$this->go_to_post();

foreach ( static::$test_actions as $beans_id => $original_action ) {
// Check the starting state.
$this->assertEquals(
array(
[
'function' => $original_action['callback'],
'accepted_args' => $original_action['args'],
),
],
$wp_filter[ $original_action['hook'] ]->callbacks[ $original_action['priority'] ][ $original_action['callback'] ]
);

Expand All @@ -160,10 +160,10 @@ public function test_should_modify_the_action_priority() {

// Check that the action's priority was modified in WordPress.
$this->assertEquals(
array(
[
'function' => $original_action['callback'],
'accepted_args' => $original_action['args'],
),
],
$callbacks_in_wp[ $modified_action['priority'] ][ $original_action['callback'] ]
);
}
Expand All @@ -175,9 +175,9 @@ public function test_should_modify_the_action_priority() {
public function test_should_modify_the_action_args() {
global $wp_filter;

$modified_action = array(
$modified_action = [
'args' => 7,
);
];

$this->go_to_post();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class Tests_BeansModifyActionArguments extends Actions_Test_Case {
public function test_should_return_false_when_args_is_non_integer() {
global $wp_filter;

$arguments = array(
$arguments = [
null,
array( 10 ),
[ 10 ],
false,
'',
);
];

$this->go_to_post();

Expand Down Expand Up @@ -66,7 +66,7 @@ public function test_should_return_false_when_args_is_non_integer() {
public function test_should_modify_action_when_args_is_zero() {
global $wp_filter;

$arguments = array( 0, 0.0, '0', '0.0' );
$arguments = [ 0, 0.0, '0', '0.0' ];

$this->go_to_post();

Expand All @@ -82,7 +82,7 @@ public function test_should_modify_action_when_args_is_zero() {
$this->assertTrue( beans_modify_action_arguments( $beans_id, $number_of_args ) );

// Check that the modified action is registered as "modified" in Beans.
$this->assertEquals( array( 'args' => (int) $number_of_args ), _beans_get_action( $beans_id, 'modified' ) );
$this->assertEquals( [ 'args' => (int) $number_of_args ], _beans_get_action( $beans_id, 'modified' ) );

// Check that the action's number of arguments was modified in WordPress.
$this->assertEquals(
Expand All @@ -107,7 +107,7 @@ public function test_should_register_as_modified_but_not_add_action() {
$this->assertFalse( beans_modify_action_arguments( $beans_id, $action['args'] ) );

// Check that the modified action is registered as "modified" in Beans.
$this->assertEquals( array( 'args' => $action['args'] ), _beans_get_action( $beans_id, 'modified' ) );
$this->assertEquals( [ 'args' => $action['args'] ], _beans_get_action( $beans_id, 'modified' ) );

// Check that the action was not added in WordPress.
$this->assertFalse( has_action( $action['hook'], $action['callback'] ) );
Expand All @@ -120,9 +120,9 @@ public function test_should_register_as_modified_but_not_add_action() {
public function test_should_modify_the_action_args() {
global $wp_filter;

$modified_action = array(
$modified_action = [
'args' => 7,
);
];

$this->go_to_post();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class Tests_BeansModifyActionCallback extends Actions_Test_Case {
* Test beans_modify_action_callback() should not modify when the callback is invalid.
*/
public function test_should_not_modify_when_invalid_callback() {
$callbacks = array(
$callbacks = [
null,
false,
'',
);
];

$this->go_to_post();

Expand Down Expand Up @@ -65,7 +65,7 @@ public function test_should_register_as_modified_but_not_add_action() {
$this->assertFalse( beans_modify_action_callback( $beans_id, $action['callback'] ) );

// Check that it did register as "modified" in Beans.
$this->assertEquals( array( 'callback' => $action['callback'] ), _beans_get_action( $beans_id, 'modified' ) );
$this->assertEquals( [ 'callback' => $action['callback'] ], _beans_get_action( $beans_id, 'modified' ) );

// Check that the action was not added in WordPress.
$this->assertFalse( has_action( $action['hook'], $action['callback'] ) );
Expand All @@ -76,9 +76,9 @@ public function test_should_register_as_modified_but_not_add_action() {
* Test beans_modify_action_callback() should modify the registered action's callback.
*/
public function test_should_modify_the_action_callback() {
$modified_action = array(
$modified_action = [
'callback' => 'my_callback',
);
];

$this->go_to_post();

Expand Down
12 changes: 6 additions & 6 deletions tests/phpunit/integration/api/actions/beansModifyActionHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class Tests_BeansModifyActionHook extends Actions_Test_Case {
* Test beans_modify_action_hook() should not modify the action when the hook is invalid.
*/
public function test_should_not_modify_when_invalid_hook() {
$hooks = array(
$hooks = [
null,
false,
array( 'foo' ),
[ 'foo' ],
'',
0,
0.0,
'0',
);
];

$this->go_to_post();

Expand Down Expand Up @@ -69,7 +69,7 @@ public function test_should_register_as_modified_but_not_add_action() {
$this->assertFalse( beans_modify_action_hook( $beans_id, $action['hook'] ) );

// Check that it did register as "modified" in Beans.
$this->assertEquals( array( 'hook' => $action['hook'] ), _beans_get_action( $beans_id, 'modified' ) );
$this->assertEquals( [ 'hook' => $action['hook'] ], _beans_get_action( $beans_id, 'modified' ) );

// Check that the action was not added in WordPress.
$this->assertFalse( has_action( $action['hook'], $action['callback'] ) );
Expand All @@ -80,9 +80,9 @@ public function test_should_register_as_modified_but_not_add_action() {
* Test beans_modify_action_hook() should modify the registered action's hook.
*/
public function test_should_modify_the_action_hook() {
$modified_action = array(
$modified_action = [
'hook' => 'foo',
);
];

$this->go_to_post();

Expand Down
Loading

0 comments on commit dc7fe4f

Please sign in to comment.