Skip to content

Commit

Permalink
Add event translations URL
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Apr 24, 2024
1 parent 5293d10 commit 2bdf8ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/urls.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public static function event_details_absolute( int $event_id ): string {
return get_site_url() . gp_url( wp_make_link_relative( $permalink ) );
}

public static function event_translations( int $event_id, string $locale, string $status = '' ): string {
return gp_url_join( self::event_details( $event_id ), 'translations', $locale, $status );
}

public static function event_edit( int $event_id ): string {
return gp_url( '/events/edit/' . $event_id );
}
Expand Down
11 changes: 11 additions & 0 deletions tests/urls.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public function test_event_details_absolute() {
$this->assertEquals( $expected, Urls::event_details_absolute( $event_id ) );
}

public function test_event_translations() {
$event_id = $this->event_factory->create_active();
$event = $this->event_repository->get_event( $event_id );

$expected = "/glotpress/events/{$event->slug()}/translations/pt";
$this->assertEquals( $expected, Urls::event_translations( $event_id, 'pt' ) );

$expected = "/glotpress/events/{$event->slug()}/translations/pt/waiting";
$this->assertEquals( $expected, Urls::event_translations( $event_id, 'pt', 'waiting' ) );
}

public function test_event_edit() {
$event_id = $this->event_factory->create_active();

Expand Down

0 comments on commit 2bdf8ca

Please sign in to comment.