|
@@ 11-28 (lines=18) @@
|
| 8 |
|
* @expectedDeprecated Jetpack_Heartbeat::cron_exec |
| 9 |
|
* @return void |
| 10 |
|
*/ |
| 11 |
|
public function test_sends_stats_data_on_heartbeat() { |
| 12 |
|
$this->make_site_active(); |
| 13 |
|
|
| 14 |
|
$heartbeat = Jetpack_Heartbeat::init(); |
| 15 |
|
add_filter( 'jetpack_heartbeat_stats_array', array( $heartbeat, 'add_stats_to_heartbeat' ) ); |
| 16 |
|
|
| 17 |
|
add_filter( 'pre_http_request', array( $this, 'pre_http_request_success' ) ); |
| 18 |
|
$heartbeat->cron_exec(); |
| 19 |
|
remove_filter( 'pre_http_request', array( $this, 'pre_http_request_success' ) ); |
| 20 |
|
|
| 21 |
|
$this->sender->do_sync(); |
| 22 |
|
|
| 23 |
|
$action = $this->server_event_storage->get_most_recent_event( 'jetpack_sync_heartbeat_stats' ); |
| 24 |
|
|
| 25 |
|
$this->delete_connection_options(); |
| 26 |
|
|
| 27 |
|
$this->assertEquals( JETPACK__VERSION, $action->args[0]['version'] ); |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
/** |
| 31 |
|
* Test dont send expensive data on heartbeat |
|
@@ 36-52 (lines=17) @@
|
| 33 |
|
* @expectedDeprecated Jetpack_Heartbeat::cron_exec |
| 34 |
|
* @return void |
| 35 |
|
*/ |
| 36 |
|
public function test_dont_send_expensive_data_on_heartbeat() { |
| 37 |
|
$this->make_site_active(); |
| 38 |
|
|
| 39 |
|
$heartbeat = Jetpack_Heartbeat::init(); |
| 40 |
|
add_filter( 'jetpack_heartbeat_stats_array', array( $heartbeat, 'add_stats_to_heartbeat' ) ); |
| 41 |
|
|
| 42 |
|
add_filter( 'pre_http_request', array( $this, 'pre_http_request_success' ) ); |
| 43 |
|
$heartbeat->cron_exec(); |
| 44 |
|
remove_filter( 'pre_http_request', array( $this, 'pre_http_request_success' ) ); |
| 45 |
|
$this->sender->do_sync(); |
| 46 |
|
|
| 47 |
|
$action = $this->server_event_storage->get_most_recent_event( 'jetpack_sync_heartbeat_stats' ); |
| 48 |
|
|
| 49 |
|
$this->delete_connection_options(); |
| 50 |
|
|
| 51 |
|
$this->assertFalse( isset( $action->args[0]['users'] ) ); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
/** |
| 55 |
|
* Test sends stats data on heartbeat on multisite |