/** * @covers Jetpack_Heartbeat::generate_stats_array * @since 3.9.0 */ public function test_generate_stats_array() { $prefix = 'test'; $result = Jetpack_Heartbeat::generate_stats_array($prefix); $this->assertNotEmpty($result); $this->assertArrayHasKey($prefix . 'version', $result); }
public static function jetpack_check_heartbeat_data() { $raw_data = Jetpack_Heartbeat::generate_stats_array(); $good = array(); $caution = array(); $bad = array(); foreach ($raw_data as $stat => $value) { // Check jetpack version if ('version' == $stat) { if (version_compare($value, JETPACK__VERSION, '<')) { $caution[$stat] = $value . " - min supported is " . JETPACK__VERSION; continue; } } // Check WP version if ('wp-version' == $stat) { if (version_compare($value, JETPACK__MINIMUM_WP_VERSION, '<')) { $caution[$stat] = $value . " - min supported is " . JETPACK__MINIMUM_WP_VERSION; continue; } } // Check PHP version if ('php-version' == $stat) { if (version_compare(PHP_VERSION, '5.2.4', '<')) { $caution[$stat] = $value . " - min supported is 5.2.4"; continue; } } // Check ID crisis if ('identitycrisis' == $stat) { if ('yes' == $value) { $bad[$stat] = $value; continue; } } // The rest are good :) $good[$stat] = $value; } $filtered_data = array('good' => $good, 'caution' => $caution, 'bad' => $bad); return $filtered_data; }