From b29dd0268bae31226f505cc74f60f975efd032d4 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 23 Jul 2020 13:58:54 -0400 Subject: [PATCH] Documentation added. --- .../test-class-connector-bbpress.php | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/tests/connectors/test-class-connector-bbpress.php b/tests/tests/connectors/test-class-connector-bbpress.php index dd727484b..71f9574af 100644 --- a/tests/tests/connectors/test-class-connector-bbpress.php +++ b/tests/tests/connectors/test-class-connector-bbpress.php @@ -1,14 +1,22 @@ register(); - // Make partial of Connector_ACF class, with mocked "log" function. + // Make partial of Connector_BbPress class, with mocked "log" function. $this->mock = $this->getMockBuilder( Connector_BbPress::class ) ->setMethods( [ 'log' ] ) ->getMock(); @@ -16,17 +24,28 @@ public function setUp() { $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 ) { @@ -48,13 +67,21 @@ function( $data ) use( &$asserted ) { 99 ); + // Do stuff. $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. $forum_id = bbp_insert_forum( [ 'post_title' => 'Test Forum' ] ); $topic_id = bbp_insert_topic( [ @@ -65,7 +92,7 @@ public function test_callback_bbp_toggle_topic_admin() { $topic = get_post( $topic_id ); // Expected log calls. - $this->mock->expects( $this->atLeastOnce() ) + $this->mock->expects( $this->once() ) ->method( 'log' ) ->with( $this->equalTo( _x( '%1$s "%2$s" topic', '1: Action, 2: Topic title', 'stream' ) ), @@ -81,7 +108,7 @@ public function test_callback_bbp_toggle_topic_admin() { $this->equalTo( 'closed' ) ); - // Do stuff + // Do stuff. do_action( 'bbp_toggle_topic_admin', bbp_close_topic( $topic_id ),