Skip to content

Commit

Permalink
test_does_not_store_action_for_draft_events()
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Feb 22, 2024
1 parent c9bb56b commit 208faa4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
22 changes: 19 additions & 3 deletions tests/lib/event-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand All @@ -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,
);
}

Expand All @@ -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,
);
}

Expand Down
12 changes: 11 additions & 1 deletion tests/stats-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 208faa4

Please sign in to comment.