diff --git a/source/Admin/Options_Tabs/Comments.php b/source/Admin/Options_Tabs/Comments.php new file mode 100644 index 0000000..e7fe804 --- /dev/null +++ b/source/Admin/Options_Tabs/Comments.php @@ -0,0 +1,28 @@ +options->is_api_transport() ) { + return $entries; + } + + $entries[2]['title'] = __( 'Comment digests', 'postmatic-premium' ); + $entries[2]['desc'] = __( + 'How many comments during a 14 hour period will trigger comment digests to be sent instead of individual comments? There is a minimum of 3.', + 'postmatic-premium' + ) . html( 'p', + __( + 'Postmatic automatically combines comment notifications on posts that go viral so your users do not get too many emails. Setting the trigger to 3 comments is good for most sites.', + 'postmatic-premium' + ) + ); + + return $entries; + } +} diff --git a/source/Filters/Options.php b/source/Filters/Options.php new file mode 100644 index 0000000..77e0280 --- /dev/null +++ b/source/Filters/Options.php @@ -0,0 +1,19 @@ +is_api_transport() ) { + array_pop( $tabs ); + $tabs[] = new Options_Tabs\Comments( Prompt_Core::$options ); + } + + } + +} \ No newline at end of file diff --git a/tests/phpunit/Admin/Options_Tabs/Comments.php b/tests/phpunit/Admin/Options_Tabs/Comments.php new file mode 100644 index 0000000..27d70a2 --- /dev/null +++ b/tests/phpunit/Admin/Options_Tabs/Comments.php @@ -0,0 +1,33 @@ +render(); + + $this->assertContains( 'Comment flood control', $content, 'Expected the old flood control title.' ); + $this->assertContains( 'comment_flood_control_trigger_count', $content, 'Expected the same flood control field name.' ); + } + + public function test_render_api() { + Prompt_Core::$options->set( 'email_transport', Prompt_Enum_Email_Transports::API ); + + $tab = new Options_Tabs\Comments( Prompt_Core::$options ); + + $content = $tab->render(); + + $this->assertContains( 'Comment digests', $content, 'Expected a new flood control title.' ); + $this->assertContains( 'comment_flood_control_trigger_count', $content, 'Expected the same flood control field name.' ); + } + +} diff --git a/tests/phpunit/Filters/Options.php b/tests/phpunit/Filters/Options.php new file mode 100644 index 0000000..a9d74d0 --- /dev/null +++ b/tests/phpunit/Filters/Options.php @@ -0,0 +1,23 @@ + 'bar' ); + + $filtered_options = Filters\Options::default_options( $original_options ); + + $this->assertEquals( + array_merge( $original_options, array( 'enable_replies_only' => '' ) ), + $filtered_options, + 'Expected custom replies only option to be added.' + ); + } + +} diff --git a/tests/phpunit/Filters/Options_Page.php b/tests/phpunit/Filters/Options_Page.php new file mode 100644 index 0000000..08781b1 --- /dev/null +++ b/tests/phpunit/Filters/Options_Page.php @@ -0,0 +1,43 @@ +assertCount( 1, $tabs, 'Expected no tabs to be added.' ); + $this->assertInstanceOf( + 'Prompt_Admin_Comment_Options_Tab', + $tabs[0], + 'Expected the original comments tab.' + ); + } + + public function test_premium_replace_tabs() { + $tabs = array( + new \Prompt_Admin_Comment_Options_Tab( \Prompt_Core::$options ), + ); + + \Prompt_Core::$options->set( 'enabled_message_types', array( 'post', 'digest' ) ); + \Prompt_Core::$options->set( 'email_transport', 'api' ); + + $tabs = Filters\Options_Page::tabs( $tabs ); + + $this->assertCount( 1, $tabs, 'Expected no tabs to be added.' ); + + $this->assertInstanceOf( + 'Postmatic\Commentium\Admin\Options_Tabs\Comments', + $tabs[0], + 'Expected the original comments tab to be replaced.' + ); + } +} \ No newline at end of file