Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions rsscloud/rsscloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ function rsscloud_parse_request( $wp ) {
}
}

function rsscloud_notify_result( $success, $msg ) {
$success = esc_attr( ent2ncr( wp_strip_all_tags( $success ) ) );
$msg = esc_attr( ent2ncr( wp_strip_all_tags( $msg ) ) );

header( 'Content-Type: text/xml' );
echo "<?xml version='1.0'?>\n";
echo "<notifyResult success='" . esc_attr( $success ) . "' msg='" . esc_attr( $msg ) . "' />\n";
exit;
if ( ! function_exists( 'rsscloud_notify_result' ) ) {
function rsscloud_notify_result( $success, $msg ) {
$success = esc_attr( ent2ncr( wp_strip_all_tags( $success ) ) );
$msg = esc_attr( ent2ncr( wp_strip_all_tags( $msg ) ) );

header( 'Content-Type: text/xml' );
echo "<?xml version='1.0'?>\n";
echo "<notifyResult success='" . esc_attr( $success ) . "' msg='" . esc_attr( $msg ) . "' />\n";
exit;
}
}

add_action( 'rss2_head', 'rsscloud_add_rss_cloud_element' );
Expand Down
23 changes: 23 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@
// Give access to tests_add_filter() function.
require_once "{$_tests_dir}/includes/functions.php";

/**
* Exception used to capture rsscloud_notify_result() calls in tests
* instead of calling exit().
*/
class RsscloudNotifyResultException extends Exception {
public $success;
public $msg;

public function __construct( $success, $msg ) {
$this->success = $success;
$this->msg = $msg;
parent::__construct( "notify_result: success=$success msg=$msg" );
}
}

/**
* Test-friendly override of rsscloud_notify_result() that throws
* instead of calling exit.
*/
function rsscloud_notify_result( $success, $msg ) {
throw new RsscloudNotifyResultException( $success, $msg );
}

/**
* Manually load the plugin being tested.
*/
Expand Down
Loading
Loading