-
Notifications
You must be signed in to change notification settings - Fork 138
Ensure status_friendly_names are provided for notifications #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
02f4d91
Ensure status_friendly_names are provided for notifications
6f98a22
Update tests/test-edit-flow-notifications.php
cojennin 2060f6a
Update tests/test-edit-flow-notifications.php
cojennin 7885f99
Update tests/test-edit-flow-notifications.php
cojennin 8335903
Update modules/notifications/notifications.php
cojennin 6eab064
Update modules/notifications/notifications.php
cojennin c534c81
Updates to tests
cojennin cc6063d
No parent classes
cojennin 1b14906
Remove build file for notifications.js
mjangda 2501d89
Merge branch 'master' into fix/notifications-status
mjangda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| <?php | ||
|
|
||
| class WP_Test_Edit_Flow_Notifications extends WP_UnitTestCase { | ||
|
|
||
| protected static $admin_user_id; | ||
| protected static $ef_notifications; | ||
|
|
||
| public static function wpSetUpBeforeClass( $factory ) { | ||
| global $edit_flow; | ||
|
|
||
| /** | ||
| * `install` is hooked to `admin_init` and `init` is hooked to `init`. | ||
| * This means when running these tests, you can encounter a situation | ||
| * where the custom post type taxonomy has not been loaded into the database | ||
| * since the tests don't trigger `admin_init` and the `install` function is where | ||
| * the custom post type taxonomy is loaded into the DB. | ||
| * | ||
| * So make sure we do one cycle of `install` followed by `init` to ensure | ||
| * custom post type taxonomy has been loaded. | ||
| */ | ||
| $edit_flow->custom_status->install(); | ||
| $edit_flow->custom_status->init(); | ||
|
|
||
| self::$admin_user_id = $factory->user->create( array( 'role' => 'administrator' ) ); | ||
|
cojennin marked this conversation as resolved.
|
||
|
|
||
| self::$ef_notifications = new EF_Notifications(); | ||
| self::$ef_notifications->install(); | ||
| self::$ef_notifications->init(); | ||
| } | ||
|
|
||
| public static function wpTearDownAfterClass() { | ||
| self::delete_user( self::$admin_user_id ); | ||
| self::$ef_notifications = null; | ||
| } | ||
|
|
||
| /** | ||
| * Test that a notification status change text is accurate when no status | ||
| * is provided in wp_insert_post | ||
| */ | ||
| function test_send_post_notification_no_status() { | ||
| global $edit_flow; | ||
|
|
||
| $edit_flow->notifications->module->options->always_notify_admin = 'on'; | ||
|
|
||
| $post = array( | ||
| 'post_author' => self::$admin_user_id, | ||
| 'post_content' => rand_str(), | ||
| 'post_title' => rand_str(), | ||
| 'post_date_gmt' => '2016-04-29 12:00:00', | ||
| ); | ||
|
|
||
| wp_insert_post( $post ); | ||
|
|
||
| $mailer = tests_retrieve_phpmailer_instance(); | ||
|
|
||
| $this->assertTrue( strpos( $mailer->get_sent()->body, 'New => Draft' ) > 0 ); | ||
| } | ||
|
|
||
| /** | ||
| * Test that a notification status change text is accurate when no status | ||
| * is provided in wp_insert_post when the custom status module is disabled | ||
| */ | ||
| function test_send_post_notification_no_status_custom_status_disabled_for_post_type() { | ||
| global $edit_flow, $typenow; | ||
|
|
||
| /** | ||
| * Prevent the registration of custom status to check if notification module will still | ||
| * work when custom status module is disabled and custom statuses are not registered | ||
| */ | ||
| $typenow = 'post'; | ||
|
|
||
| $edit_flow->custom_status->module->options->post_types = array( 'page' ); | ||
| /** | ||
| * Initiate a full cycle (install/init) to ensure the core statuses are returned | ||
| * instead of custom stautses (since we're disabling the module for this post type) | ||
| */ | ||
| $edit_flow->custom_status->install(); | ||
| $edit_flow->custom_status->init(); | ||
|
mjangda marked this conversation as resolved.
|
||
|
|
||
| $edit_flow->notifications->module->options->always_notify_admin = 'on'; | ||
|
|
||
| $post = array( | ||
| 'post_author' => self::$admin_user_id, | ||
| 'post_content' => rand_str(), | ||
| 'post_title' => rand_str(), | ||
| 'post_date_gmt' => '2016-04-29 12:00:00', | ||
| ); | ||
|
|
||
| wp_insert_post( $post ); | ||
|
|
||
| $mailer = tests_retrieve_phpmailer_instance(); | ||
|
|
||
| $this->assertTrue( strpos( $mailer->get_sent()->body, 'New => Draft' ) > 0 ); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.