Permalink
Browse files

Add WPCOM_Liveblog_Entry_Query::has_any()

Checks if there are any entries at all.
  • Loading branch information...
1 parent 75093ff commit ba2507705d790453b4a7e31a553c2ef134f988a5 @nb nb committed Dec 18, 2012
Showing with 13 additions and 0 deletions.
  1. +4 −0 classes/class-wpcom-liveblog-entry-query.php
  2. +9 −0 t/test-entry-query.php
@@ -125,6 +125,10 @@ public function get_between_timestamps( $start_timestamp, $end_timestamp ) {
return self::remove_replaced_entries( $entries_between );
}
+ public function has_any() {
+ return (bool)$this->get();
+ }
+
private function get_all_entries_asc() {
$cached_entries_asc_key = $this->key . '_entries_asc_' . $this->post_id;
$cached_entries_asc = wp_cache_get( $cached_entries_asc_key, 'liveblog' );
View
@@ -93,6 +93,15 @@ function test_get_by_id_should_not_return_entries_for_trashed_comments() {
$this->assertNull( $this->entry_query->get_by_id( $comment_id ) );
}
+ function test_has_any_returns_false_if_no_entries() {
+ $this->assertFalse( $this->entry_query->has_any() );
+ }
+
+ function test_has_any_returns_true_if_we_add_some_entries() {
+ $this->create_comment();
+ $this->assertTrue( $this->entry_query->has_any() );
+ }
+
private function create_comment( $args = array() ) {
$defaults = array(
'comment_post_ID' => $this->entry_query->post_id,

0 comments on commit ba25077

Please sign in to comment.