-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable disabling the newsletter send failure email notification
- Loading branch information
Showing
4 changed files
with
87 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,50 @@ | ||
<?php | ||
/** | ||
* Test Newsletter Service Provider class. | ||
* | ||
* @package Newspack_Newsletters | ||
*/ | ||
|
||
/** | ||
* Newsletters Service Provider class Test. | ||
*/ | ||
class Newsletters_Newsletter_Service_Provider_Test extends WP_UnitTestCase { | ||
/** | ||
* Test set up. | ||
*/ | ||
public function set_up() { | ||
// Set an ESP. | ||
\Newspack_Newsletters::set_service_provider( 'mailchimp' ); | ||
// Ensure the API key is not set (might be set by a different test). | ||
delete_option( 'newspack_mailchimp_api_key' ); | ||
|
||
add_filter( | ||
'wp_die_handler', | ||
function() { | ||
return 'handle_wpdie_in_tests';} | ||
); | ||
} | ||
|
||
/** | ||
* Test sending a newsletter. | ||
*/ | ||
public function test_service_provider_send_newsletter_unconfigured() { | ||
// Create a draft and then publish, to trigger a sending. | ||
$post_id = self::factory()->post->create( | ||
[ | ||
'post_type' => \Newspack_Newsletters::NEWSPACK_NEWSLETTERS_CPT, | ||
'post_status' => 'draft', | ||
] | ||
); | ||
|
||
$this->expectException( WPDieException::class ); | ||
$this->expectExceptionMessage( 'No Mailchimp API key available.' ); | ||
|
||
wp_update_post( | ||
[ | ||
'ID' => $post_id, | ||
'post_status' => 'publish', | ||
] | ||
); | ||
} | ||
} |