diff --git a/tests/lib/event-factory.php b/tests/lib/event-factory.php index b8e3a1bc..e1e630ca 100644 --- a/tests/lib/event-factory.php +++ b/tests/lib/event-factory.php @@ -20,13 +20,29 @@ public function __construct( $factory = null ) { ); } + public function create_draft(): int { + $now = new DateTimeImmutable( 'now', new DateTimeZone( 'UTC' ) ); + + $event_id = $this->create_event( + $now->modify( '-1 hours' ), + $now->modify( '+1 hours' ), + array(), + ); + + $event = get_post( $event_id ); + $event->post_status = 'draft'; + wp_update_post( $event ); + + return $event_id; + } + public function create_active( array $attendee_ids = array() ): int { $now = new DateTimeImmutable( 'now', new DateTimeZone( 'UTC' ) ); return $this->create_event( $now->modify( '-1 hours' ), $now->modify( '+1 hours' ), - $attendee_ids + $attendee_ids, ); } @@ -36,7 +52,7 @@ public function create_inactive_past( array $attendee_ids = array() ): int { return $this->create_event( $now->modify( '-2 hours' ), $now->modify( '-1 hours' ), - $attendee_ids + $attendee_ids, ); } @@ -46,7 +62,7 @@ public function create_inactive_future( array $attendee_ids = array() ): int { return $this->create_event( $now->modify( '+1 hours' ), $now->modify( '+2 hours' ), - $attendee_ids + $attendee_ids, ); } diff --git a/tests/stats-listener.php b/tests/stats-listener.php index 7d067cd4..cb1edb93 100644 --- a/tests/stats-listener.php +++ b/tests/stats-listener.php @@ -26,7 +26,17 @@ private function get_stats(): array { } public function test_does_not_store_action_for_draft_events() { - $this->markTestSkipped( 'TODO' ); + $this->set_normal_user_as_current(); + $user_id = wp_get_current_user()->ID; + + $this->event_factory->create_draft(); + $this->event_factory->create_draft(); + + $this->translation_factory->create( $user_id ); + // Stats_Listener will have been called. + + $stats = $this->get_stats(); + $this->assertEmpty( $stats ); } public function test_does_not_store_action_for_inactive_events() {