diff --git a/composer.json b/composer.json index abf796eaf..dd200d980 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "wpackagist-plugin/easy-digital-downloads": "^2.9.23", "wpackagist-plugin/jetpack": "^8.7", "wpackagist-plugin/user-switching": "^1.5.5", + "wpackagist-plugin/bbpress": "^2.6.5", "wpsh/local": "^0.2.3" }, "config": { diff --git a/composer.lock b/composer.lock index f6f34358b..8319f1efb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b3a66b40eacb8dece6a3c25e6dda1348", + "content-hash": "5ebdf963d1b1b5f28077dc373e6ceee1", "packages": [ { "name": "composer/installers", @@ -544,16 +544,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.4.5", + "version": "1.4.6", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f28d44c286812c714741478d968104c5e604a1d4" + "reference": "f27e06cd9675801df441b3656569b328e04aa37c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4", - "reference": "f28d44c286812c714741478d968104c5e604a1d4", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c", "shasum": "" }, "require": { @@ -561,7 +561,8 @@ "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "autoload": { @@ -587,7 +588,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.5" + "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" }, "funding": [ { @@ -603,7 +604,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T08:04:11+00:00" + "time": "2021-03-25T17:01:18+00:00" }, { "name": "cweagans/composer-patches", @@ -713,16 +714,16 @@ }, { "name": "gettext/gettext", - "version": "v4.8.3", + "version": "v4.8.4", "source": { "type": "git", "url": "https://github.com/php-gettext/Gettext.git", - "reference": "57ff4fb16647e78e80a5909fe3c190f1c3110321" + "reference": "58bc0f7f37e78efb0f9758f93d4a0f669f0f84a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-gettext/Gettext/zipball/57ff4fb16647e78e80a5909fe3c190f1c3110321", - "reference": "57ff4fb16647e78e80a5909fe3c190f1c3110321", + "url": "https://api.github.com/repos/php-gettext/Gettext/zipball/58bc0f7f37e78efb0f9758f93d4a0f669f0f84a1", + "reference": "58bc0f7f37e78efb0f9758f93d4a0f669f0f84a1", "shasum": "" }, "require": { @@ -774,9 +775,23 @@ "support": { "email": "oom@oscarotero.com", "issues": "https://github.com/oscarotero/Gettext/issues", - "source": "https://github.com/php-gettext/Gettext/tree/v4.8.3" + "source": "https://github.com/php-gettext/Gettext/tree/v4.8.4" }, - "time": "2020-11-18T22:35:49+00:00" + "funding": [ + { + "url": "https://paypal.me/oscarotero", + "type": "custom" + }, + { + "url": "https://github.com/oscarotero", + "type": "github" + }, + { + "url": "https://www.patreon.com/misteroom", + "type": "patreon" + } + ], + "time": "2021-03-10T19:35:49+00:00" }, { "name": "gettext/languages", @@ -916,16 +931,16 @@ }, { "name": "guzzlehttp/promises", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "60d379c243457e073cff02bc323a2a86cb355631" + "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/60d379c243457e073cff02bc323a2a86cb355631", - "reference": "60d379c243457e073cff02bc323a2a86cb355631", + "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d", + "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d", "shasum": "" }, "require": { @@ -965,22 +980,22 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.4.0" + "source": "https://github.com/guzzle/promises/tree/1.4.1" }, - "time": "2020-09-30T07:37:28+00:00" + "time": "2021-03-07T09:25:29+00:00" }, { "name": "guzzlehttp/psr7", - "version": "1.7.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3" + "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3", - "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1", + "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1", "shasum": "" }, "require": { @@ -1040,9 +1055,9 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.7.0" + "source": "https://github.com/guzzle/psr7/tree/1.8.1" }, - "time": "2020-09-30T07:37:11+00:00" + "time": "2021-03-21T16:25:00+00:00" }, { "name": "humanmade/mercator", @@ -1086,20 +1101,20 @@ }, { "name": "johnpbloch/wordpress", - "version": "5.6.1", + "version": "5.7.0", "source": { "type": "git", "url": "https://github.com/johnpbloch/wordpress.git", - "reference": "d7a597988102967cdfc28851b6b897d018613823" + "reference": "22ea3c6aa631e296c528f58a67371fb2a5e674f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/johnpbloch/wordpress/zipball/d7a597988102967cdfc28851b6b897d018613823", - "reference": "d7a597988102967cdfc28851b6b897d018613823", + "url": "https://api.github.com/repos/johnpbloch/wordpress/zipball/22ea3c6aa631e296c528f58a67371fb2a5e674f2", + "reference": "22ea3c6aa631e296c528f58a67371fb2a5e674f2", "shasum": "" }, "require": { - "johnpbloch/wordpress-core": "5.6.1", + "johnpbloch/wordpress-core": "5.7.0", "johnpbloch/wordpress-core-installer": "^1.0 || ^2.0", "php": ">=5.6.20" }, @@ -1128,20 +1143,20 @@ "source": "http://core.trac.wordpress.org/browser", "wiki": "http://codex.wordpress.org/" }, - "time": "2021-02-03T21:27:41+00:00" + "time": "2021-03-09T20:32:28+00:00" }, { "name": "johnpbloch/wordpress-core", - "version": "5.6.1", + "version": "5.7.0", "source": { "type": "git", "url": "https://github.com/johnpbloch/wordpress-core.git", - "reference": "82592ec73d42cf784da38adb0028a24dbacab1b4" + "reference": "8b057056692ca196aaa7a7ddd915f29426922c6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/johnpbloch/wordpress-core/zipball/82592ec73d42cf784da38adb0028a24dbacab1b4", - "reference": "82592ec73d42cf784da38adb0028a24dbacab1b4", + "url": "https://api.github.com/repos/johnpbloch/wordpress-core/zipball/8b057056692ca196aaa7a7ddd915f29426922c6d", + "reference": "8b057056692ca196aaa7a7ddd915f29426922c6d", "shasum": "" }, "require": { @@ -1149,7 +1164,7 @@ "php": ">=5.6.20" }, "provide": { - "wordpress/core-implementation": "5.6.1" + "wordpress/core-implementation": "5.7.0" }, "type": "wordpress-core", "notification-url": "https://packagist.org/downloads/", @@ -1176,7 +1191,7 @@ "source": "https://core.trac.wordpress.org/browser", "wiki": "https://codex.wordpress.org/" }, - "time": "2021-02-03T21:27:35+00:00" + "time": "2021-03-09T20:32:23+00:00" }, { "name": "johnpbloch/wordpress-core-installer", @@ -3152,16 +3167,16 @@ }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.10.2", + "version": "v2.11.0", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "0775e0c683badad52c03b11c2cd86a9fdecb937a" + "reference": "e76e816236f401458dd8e16beecab905861b5867" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/0775e0c683badad52c03b11c2cd86a9fdecb937a", - "reference": "0775e0c683badad52c03b11c2cd86a9fdecb937a", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/e76e816236f401458dd8e16beecab905861b5867", + "reference": "e76e816236f401458dd8e16beecab905861b5867", "shasum": "" }, "require": { @@ -3201,7 +3216,7 @@ "source": "https://github.com/sirbrillig/phpcs-variable-analysis", "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" }, - "time": "2021-01-08T16:31:05+00:00" + "time": "2021-03-09T22:32:14+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -5097,16 +5112,16 @@ }, { "name": "wp-cli/export-command", - "version": "v2.0.5", + "version": "v2.0.6", "source": { "type": "git", "url": "https://github.com/wp-cli/export-command.git", - "reference": "015725833e7e0a89b188df4fb66b88415d4414ec" + "reference": "df2e1ff4fb7e969c54c57febccdc9d2de1e5f499" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/export-command/zipball/015725833e7e0a89b188df4fb66b88415d4414ec", - "reference": "015725833e7e0a89b188df4fb66b88415d4414ec", + "url": "https://api.github.com/repos/wp-cli/export-command/zipball/df2e1ff4fb7e969c54c57febccdc9d2de1e5f499", + "reference": "df2e1ff4fb7e969c54c57febccdc9d2de1e5f499", "shasum": "" }, "require": { @@ -5153,9 +5168,9 @@ "homepage": "https://github.com/wp-cli/export-command", "support": { "issues": "https://github.com/wp-cli/export-command/issues", - "source": "https://github.com/wp-cli/export-command/tree/v2.0.5" + "source": "https://github.com/wp-cli/export-command/tree/v2.0.6" }, - "time": "2020-12-07T19:30:08+00:00" + "time": "2021-01-14T12:16:33+00:00" }, { "name": "wp-cli/extension-command", @@ -5694,16 +5709,16 @@ }, { "name": "wp-cli/php-cli-tools", - "version": "v0.11.11", + "version": "v0.11.12", "source": { "type": "git", "url": "https://github.com/wp-cli/php-cli-tools.git", - "reference": "fe9c7c44a9e1bf2196ec51dc38da0593dbf2993f" + "reference": "e472e08489f7504d9e8c5c5a057e1419cd1b2b3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/fe9c7c44a9e1bf2196ec51dc38da0593dbf2993f", - "reference": "fe9c7c44a9e1bf2196ec51dc38da0593dbf2993f", + "url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/e472e08489f7504d9e8c5c5a057e1419cd1b2b3e", + "reference": "e472e08489f7504d9e8c5c5a057e1419cd1b2b3e", "shasum": "" }, "require": { @@ -5723,15 +5738,15 @@ "MIT" ], "authors": [ - { - "name": "James Logsdon", - "email": "jlogsdon@php.net", - "role": "Developer" - }, { "name": "Daniel Bachhuber", "email": "daniel@handbuilt.co", "role": "Maintainer" + }, + { + "name": "James Logsdon", + "email": "jlogsdon@php.net", + "role": "Developer" } ], "description": "Console utilities for PHP", @@ -5742,9 +5757,9 @@ ], "support": { "issues": "https://github.com/wp-cli/php-cli-tools/issues", - "source": "https://github.com/wp-cli/php-cli-tools/tree/master" + "source": "https://github.com/wp-cli/php-cli-tools/tree/v0.11.12" }, - "time": "2018-09-04T13:28:00+00:00" + "time": "2021-03-03T12:43:49+00:00" }, { "name": "wp-cli/rewrite-command", @@ -6483,16 +6498,16 @@ }, { "name": "wp-phpunit/wp-phpunit", - "version": "5.6.1", + "version": "5.7.0", "source": { "type": "git", "url": "https://github.com/wp-phpunit/wp-phpunit.git", - "reference": "f6b3fb65bccc0ff70b3bc7cc241935597dbd5562" + "reference": "5ab77c1e1328e9bee65f60c246e33b13fc202375" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-phpunit/wp-phpunit/zipball/f6b3fb65bccc0ff70b3bc7cc241935597dbd5562", - "reference": "f6b3fb65bccc0ff70b3bc7cc241935597dbd5562", + "url": "https://api.github.com/repos/wp-phpunit/wp-phpunit/zipball/5ab77c1e1328e9bee65f60c246e33b13fc202375", + "reference": "5ab77c1e1328e9bee65f60c246e33b13fc202375", "shasum": "" }, "type": "library", @@ -6527,7 +6542,7 @@ "issues": "https://github.com/wp-phpunit/issues", "source": "https://github.com/wp-phpunit/wp-phpunit" }, - "time": "2021-02-04T18:24:14+00:00" + "time": "2021-03-10T17:57:07+00:00" }, { "name": "wpackagist-plugin/advanced-custom-fields", @@ -6547,17 +6562,35 @@ "type": "wordpress-plugin", "homepage": "https://wordpress.org/plugins/advanced-custom-fields/" }, + { + "name": "wpackagist-plugin/bbpress", + "version": "2.6.6", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/bbpress/", + "reference": "tags/2.6.6" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/bbpress.2.6.6.zip" + }, + "require": { + "composer/installers": "~1.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/bbpress/" + }, { "name": "wpackagist-plugin/easy-digital-downloads", - "version": "2.9.26", + "version": "2.10.1", "source": { "type": "svn", "url": "https://plugins.svn.wordpress.org/easy-digital-downloads/", - "reference": "tags/2.9.26" + "reference": "tags/2.10.1" }, "dist": { "type": "zip", - "url": "https://downloads.wordpress.org/plugin/easy-digital-downloads.2.9.26.zip" + "url": "https://downloads.wordpress.org/plugin/easy-digital-downloads.2.10.1.zip" }, "require": { "composer/installers": "~1.0" diff --git a/connectors/class-connector-bbpress.php b/connectors/class-connector-bbpress.php index f05013bc0..88ddfeffa 100644 --- a/connectors/class-connector-bbpress.php +++ b/connectors/class-connector-bbpress.php @@ -202,8 +202,8 @@ public function log_override( $data ) { } elseif ( 'posts' === $data['connector'] && in_array( $data['context'], array( 'forum', 'topic', 'reply' ), true ) ) { if ( 'reply' === $data['context'] ) { if ( 'updated' === $data['action'] ) { - /* translators: %s: a post title (e.g. "Hello World") */ - $data['message'] = esc_html__( 'Replied on "%s"', 'stream' ); + /* translators: %1$s: a post title (e.g. "Hello World") */ + $data['message'] = esc_html__( 'Replied on "%1$s"', 'stream' ); $data['args']['post_title'] = get_post( wp_get_post_parent_id( $data['object_id'] ) )->post_title; } $data['args']['post_title'] = sprintf( @@ -222,7 +222,7 @@ public function log_override( $data ) { } /** - * Tracks togging the forum topics + * Tracks toggling the forum topics * * @param bool $success If action success. * @param \WP_Post $post_data Post data. diff --git a/phpunit.xml b/phpunit.xml index f37a7bf54..20edcad11 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,7 +10,7 @@ diff --git a/tests/tests/connectors/test-class-connector-bbpress.php b/tests/tests/connectors/test-class-connector-bbpress.php new file mode 100644 index 000000000..aa5419064 --- /dev/null +++ b/tests/tests/connectors/test-class-connector-bbpress.php @@ -0,0 +1,128 @@ +plugin->connectors->unload_connectors(); + + $post_connector = new Connector_Posts(); + $post_connector->register(); + + // Make partial of Connector_BbPress class, with mocked "log" function. + $this->mock = $this->getMockBuilder( Connector_BbPress::class ) + ->setMethods( array( 'log' ) ) + ->getMock(); + + $this->mock->register(); + } + + /** + * Runs after each test + */ + public function tearDown() { + parent::tearDown(); + } + + /** + * Confirm that bbPress is installed and active. + */ + public function test_bbpress_installed_and_activated() { + $this->assertTrue( class_exists( 'bbPress' ) ); + } + + /** + * Tests the "log_override" callback + */ + public function test_log_override() { + // Has asserted flag. + $asserted = false; + + // Set assertion callback. + add_action( + 'wp_stream_log_data', + function( $data ) use( &$asserted ) { + $message = _x( + '"%1$s" %2$s published', + '1: Post title, 2: Post type singular name', + 'stream' + ); + + $this->assertSame( 'bbpress', $data['connector'] ); + $this->assertSame( $message, $data['message'] ); + $this->assertSame( 'Test Forum', $data['args']['post_title'] ); + $this->assertSame( 'forum', $data['context'] ); + $this->assertSame( 'updated', $data['action'] ); + $asserted = true; + + return $data; + }, + 99 + ); + + // Create forum to trigger Connector_Posts' transition_status callback. + $forum_id = bbp_insert_forum( [ 'post_title' => 'Test Forum' ] ); + + // Check ID. + $this->assertGreaterThan( 0, $forum_id ); + + // Confirm that assertion callback executed. + $this->assertTrue( $asserted ); + } + + /** + * Test "test_callback_bbp_toggle_topic_admin" callback. + */ + public function test_callback_bbp_toggle_topic_admin() { + // Create forum and topic for later use. + $forum_id = bbp_insert_forum( [ 'post_title' => 'Test Forum' ] ); + $topic_id = bbp_insert_topic( + array( + 'post_title' => 'Test Topic', + 'post_parent' => $forum_id, + ) + ); + $topic = get_post( $topic_id ); + + // Expected log calls. + $this->mock->expects( $this->once() ) + ->method( 'log' ) + ->with( + $this->equalTo( _x( '%1$s "%2$s" topic', '1: Action, 2: Topic title', 'stream' ) ), + $this->equalTo( + array( + 'action_title' => esc_html_x( 'Closed', 'bbpress', 'stream' ), + 'topic_title' => $topic->post_title, + 'action' => 'closed', + ) + ), + $this->equalTo( $topic_id ), + $this->equalTo( 'topic' ), + $this->equalTo( 'closed' ) + ); + + // Manually trigger callback. + do_action( + 'bbp_toggle_topic_admin', + bbp_close_topic( $topic_id ), + array( 'ID' => $topic_id ), + 'bbp_toggle_topic_close', + array( + 'bbp_topic_toggle_notice' => 'closed', + 'topic_id' => $topic_id + ) + ); + + // Check callback test action. + $this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_bbp_toggle_topic_admin' ) ); + } +}