Skip to content

Commit

Permalink
Add test for non-logged in user
Browse files Browse the repository at this point in the history
  • Loading branch information
trymebytes committed Dec 11, 2024
1 parent 35bc39d commit 94c8a52
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tests/event/event-form-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@
use Wporg\TranslationEvents\Attendee\Attendee_Repository;
use Wporg\TranslationEvents\Event\Event_Repository;
use Wporg\TranslationEvents\Event\Event_Form_Handler;


use Wporg\TranslationEvents\Tests\Event_Form_Handler_Factory;

class Event_Form_Handler_Test extends Base_Test {
private Event_Repository $event_repository;
private Attendee_Repository $attendee_repository;
private $event_form_handler;
private Event_Form_Handler $event_form_handler;
private Event_Form_Handler_Factory $event_form_handler_factory;

public function setUp(): void {
parent::setUp();
$this->attendee_repository = new Attendee_Repository();
$this->event_repository = new Event_Repository( $this->now, $this->attendee_repository );
$this->event_form_handler = new Event_Form_Handler( $this->now, $this->event_repository );
$this->attendee_repository = new Attendee_Repository();
$this->event_repository = new Event_Repository( $this->now, $this->attendee_repository );
$this->event_form_handler = new Event_Form_Handler( $this->now, $this->event_repository );
$this->event_form_handler_factory = new Event_Form_Handler_Factory();
}

/**
* Test that the user must be logged in to create an event.
*
* @return void
*/
public function test_user_is_not_logged_in() {
wp_set_current_user( 0 );
$form_data = $this->event_form_handler_factory->future_inactive_event_form_data( 'create_event', $this->now );
$response = $this->event_form_handler->handle( $form_data );

$this->assertEquals( '{"success":false,"data":"The user must be logged in."}', $response );
}
}

0 comments on commit 94c8a52

Please sign in to comment.