diff --git a/composer.lock b/composer.lock index 23d09007..46f7e070 100644 --- a/composer.lock +++ b/composer.lock @@ -4130,16 +4130,16 @@ }, { "name": "wp-cli/config-command", - "version": "v2.0.6", + "version": "v2.0.7", "source": { "type": "git", "url": "https://github.com/wp-cli/config-command.git", - "reference": "f204bc62c557adb08f32a84683cc1dbfd23e6d96" + "reference": "6468e97ab2ace5b0a448d9e19091d42f6461b466" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/config-command/zipball/f204bc62c557adb08f32a84683cc1dbfd23e6d96", - "reference": "f204bc62c557adb08f32a84683cc1dbfd23e6d96", + "url": "https://api.github.com/repos/wp-cli/config-command/zipball/6468e97ab2ace5b0a448d9e19091d42f6461b466", + "reference": "6468e97ab2ace5b0a448d9e19091d42f6461b466", "shasum": "" }, "require": { @@ -4195,7 +4195,7 @@ ], "description": "Generates and reads the wp-config.php file.", "homepage": "https://github.com/wp-cli/config-command", - "time": "2020-06-11T00:17:12+00:00" + "time": "2020-10-31T11:20:34+00:00" }, { "name": "wp-cli/core-command", @@ -5625,16 +5625,16 @@ }, { "name": "wp-cli/shell-command", - "version": "v2.0.5", + "version": "v2.0.6", "source": { "type": "git", "url": "https://github.com/wp-cli/shell-command.git", - "reference": "f655611701ed331c336932091860e66839a535f3" + "reference": "d29fceda4c79b2e6e4295b563427f76e3b7bc1ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/shell-command/zipball/f655611701ed331c336932091860e66839a535f3", - "reference": "f655611701ed331c336932091860e66839a535f3", + "url": "https://api.github.com/repos/wp-cli/shell-command/zipball/d29fceda4c79b2e6e4295b563427f76e3b7bc1ba", + "reference": "d29fceda4c79b2e6e4295b563427f76e3b7bc1ba", "shasum": "" }, "require": { @@ -5675,7 +5675,7 @@ ], "description": "Opens an interactive PHP console for running and testing PHP code.", "homepage": "https://github.com/wp-cli/shell-command", - "time": "2020-06-12T00:17:09+00:00" + "time": "2020-10-31T08:19:44+00:00" }, { "name": "wp-cli/super-admin-command", @@ -6018,7 +6018,7 @@ }, { "name": "wp-phpunit/wp-phpunit", - "version": "5.5.1", + "version": "5.5.3", "source": { "type": "git", "url": "https://github.com/wp-phpunit/wp-phpunit.git", diff --git a/tests/tests/connectors/test-class-connector-buddypress.php b/tests/tests/connectors/test-class-connector-buddypress.php index ae857953..5f4c7efa 100644 --- a/tests/tests/connectors/test-class-connector-buddypress.php +++ b/tests/tests/connectors/test-class-connector-buddypress.php @@ -1,26 +1,50 @@ mock = $this->getMockBuilder( Connector_BuddyPress::class ) - ->setMethods( [ 'log' ] ) + ->setMethods( array( 'log' ) ) ->getMock(); $this->mock->register(); } + /** + * Run after each test + */ public function tearDown() { parent::tearDown(); } public function test_bbpress_installed_and_activated() { $this->assertTrue( is_callable( 'buddypress' ) ); - buddypress(); } public function test_option_callbacks() { @@ -28,7 +52,7 @@ public function test_option_callbacks() { $this->mock->expects( $this->atLeastOnce() ) ->method( 'log' ) ->withConsecutive( - [ + array( /* translators: %s: setting name (e.g. "Group Creation") */ $this->equalTo( _( '"%s" setting updated', 'stream' ) ), $this->equalTo( @@ -43,8 +67,8 @@ public function test_option_callbacks() { $this->equalTo( null ), $this->equalTo( 'settings' ), $this->equalTo( 'updated' ) - ], - [ + ), + array( /* translators: %s: setting name (e.g. "Group Creation") */ $this->equalTo( _( '"%s" setting updated', 'stream' ) ), $this->equalTo( @@ -59,8 +83,8 @@ public function test_option_callbacks() { $this->equalTo( null ), $this->equalTo( 'settings' ), $this->equalTo( 'updated' ) - ], - [ + ), + array( /* translators: %s: setting name (e.g. "Group Creation") */ $this->equalTo( _( '"%s" setting updated', 'stream' ) ), $this->equalTo( @@ -75,58 +99,134 @@ public function test_option_callbacks() { $this->equalTo( null ), $this->equalTo( 'settings' ), $this->equalTo( 'updated' ) - ], - [ - sprintf( - // translators: Placeholder refers to component title (e.g. "Members") - __( '"%1$s" component %2$s', 'stream' ), - 'Extended Profiles', - 'activated' + ), + array( + $this->equalTo( + sprintf( + // translators: Placeholder refers to component title (e.g. "Members") + __( '"%1$s" component %2$s', 'stream' ), + 'Extended Profiles', + 'activated' + ) ), - array( - 'option' => 'xprofile', - 'option_key' => 'bp-active-components', - 'old_value' => null, - 'value' => array( - 'title' => __( 'Extended Profiles', 'buddypress' ), - 'description' => __( 'Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress' ) - ), + $this->equalTo( + array( + 'option' => 'xprofile', + 'option_key' => 'bp-active-components', + 'old_value' => null, + 'value' => array( + 'title' => __( 'Extended Profiles', 'buddypress' ), + 'description' => __( 'Customize your community with fully editable profile fields that allow your users to describe themselves.', 'buddypress' ) + ), + ) ), - null, - 'components', - 'activated' - ] + + $this->equalTo( null ), + $this->equalTo( 'components' ), + $this->equalTo( 'activated' ), + ) ); - // Do stuff. + // Modify BuddyPress-related options to trigger callbacks. add_option( 'bp_restrict_group_creation', false ); update_option( 'bp_restrict_group_creation', true ); delete_option( 'bp_restrict_group_creation' ); bp_update_option( 'bp-active-components', bp_core_get_components( 'all' ) ); - // Check that all callback test actions were executed. - $this->assertFalse( 0 === did_action( 'wp_stream_test_callback_add_option' ) ); - $this->assertFalse( 0 === did_action( 'wp_stream_test_callback_update_option' ) ); - $this->assertFalse( 0 === did_action( 'wp_stream_test_callback_delete_option' ) ); + // Check callback test actions. + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_add_option' ) ); + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_update_option' ) ); + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_delete_option' ) ); } public function test_activity_callbacks() { - // Expected log actions. - $this->mock->expects( $this->atLeastOnce() ) - ->method( 'log' ); - - // Do stuff. + // Create activity for later use. $activity_id = \bp_activity_add( array( 'component' => 'testComponent', 'content' => 'Testing testing 123' ) ); + + $activity = new \BP_Activity_Activity( $activity_id ); + + // Expected log actions. + $this->mock->expects( $this->atLeastOnce() ) + ->method( 'log' ) + ->withConsecutive( + array( + $this->equalTo( + sprintf( + /* translators: %s an activity title (e.g. "Update") */ + __( 'Marked activity "%s" as spam', 'stream' ), + wp_strip_all_tags( $activity->action ) + ) + ), + $this->equalTo( + array( + 'id' => $activity->id, + 'item_id' => $activity->item_id, + 'type' => $activity->type, + 'author' => $activity->user_id, + ) + ), + $this->equalTo( $activity->id ), + $this->equalTo( $activity->component ), + $this->equalTo( 'spammed' ), + ), + array( + $this->equalTo( + sprintf( + /* translators: %s: an activity title (e.g. "Update") */ + __( 'Unmarked activity "%s" as spam', 'stream' ), + wp_strip_all_tags( $activity->action ) + ) + ), + $this->equalTo( + array( + 'id' => $activity->id, + 'item_id' => $activity->item_id, + 'type' => $activity->type, + 'author' => $activity->user_id, + ) + ), + $this->equalTo( $activity->id ), + $this->equalTo( $activity->component ), + $this->equalTo( 'unspammed' ), + ), + array( + $this->equalTo( + sprintf( + /* translators: %s: an activity title (e.g. "Update") */ + __( '"%s" activity deleted', 'stream' ), + wp_strip_all_tags( $activity->action ) + ) + ), + $this->equalTo( + array( + 'id' => $activity->id, + 'item_id' => $activity->item_id, + 'type' => $activity->type, + 'author' => $activity->user_id, + ) + ), + $this->equalTo( $activity->id ), + $this->equalTo( $activity->component ), + $this->equalTo( 'deleted' ), + ) + ); + + // Update activity to trigger callbacks. + \bp_activity_mark_as_spam( $activity_id ); + \bp_activity_mark_as_ham( $activity_id ); \bp_activity_delete_by_activity_id( $activity_id ); - // Check that all callback test actions were executed. - $this->assertFalse( 0 === did_action( 'wp_stream_test_callback_' ) ); + // Check callback test actions. + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_bp_activity_mark_as_spam' ) ); + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_bp_activity_mark_as_ham' ) ); + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_bp_before_activity_delete' ) ); + $this->assertFalse( 0 === did_action( $this->action_prefix . 'callback_bp_activity_deleted_activities' ) ); } public function test_group_action_callbacks() {