diff --git a/includes/urls.php b/includes/urls.php index 5e197736..4532cf55 100644 --- a/includes/urls.php +++ b/includes/urls.php @@ -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 ); } diff --git a/tests/urls.php b/tests/urls.php index af2eda20..5172ebd0 100644 --- a/tests/urls.php +++ b/tests/urls.php @@ -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();