Skip to content
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

WIP alert type tests implemented #1196

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions alerts/class-alert-type-die.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @package WP_Stream
*/
class Alert_Type_Die extends Alert_Type {
class Alert_Type_Die extends Alert_Type { // @codingStandardsIgnoreLine

/**
* Alert type name
Expand Down Expand Up @@ -40,6 +40,6 @@ public function alert( $record_id, $recordarr, $options ) {
echo '<pre>';
print_r( $recordarr ); // @codingStandardsIgnoreLine debug not loaded in production
echo '</pre>';
die( 'You have been notified!' );
throw new Die_Exception( 'You have been notified!' );
}
}
1 change: 1 addition & 0 deletions alerts/class-alert-type-ifttt.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function __construct( $plugin ) {
*/
public function alert( $record_id, $recordarr, $alert ) {
$recordarr['ID'] = $record_id;
error_log( 'here' );
$this->notify_ifttt( $alert, $recordarr );
}

Expand Down
1 change: 1 addition & 0 deletions classes/class-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public static function update_record_triggered_alerts( $record, $alert_slug, $al
} elseif ( ! array_key_exists( $alert_slug, $alerts_triggered ) || ! is_array( $alerts_triggered[ $alert_slug ] ) ) {
$alerts_triggered[ $alert_slug ] = $alert_meta;
}

return $record->update_meta( Alerts::ALERTS_TRIGGERED_META_KEY, $alerts_triggered );
}

Expand Down
1 change: 1 addition & 0 deletions classes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function get_records( $args ) {

// Additional property fields.
$properties = array(
'ID' => null,
'user_id' => null,
'user_role' => null,
'ip' => null,
Expand Down
14 changes: 14 additions & 0 deletions classes/class-die-exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* Reusable utility class acts as a suppress for the "Die" Alert type.
* Debugging only
*
* @package WP_Stream
*/

namespace WP_Stream;

/**
* Used to Die safely.
*/
class Die_Exception extends \Exception {}
3 changes: 3 additions & 0 deletions classes/class-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function query( $args ) {
/**
* PARSE CORE PARAMS
*/
if ( is_numeric( $args['ID'] ) ) {
$where .= $wpdb->prepare( " AND $wpdb->stream.ID = %d", $args['ID'] );
}
if ( is_numeric( $args['site_id'] ) ) {
$where .= $wpdb->prepare( " AND $wpdb->stream.site_id = %d", $args['site_id'] );
}
Expand Down
Loading