From 899b931b89f3c28f84fe952fa1689852e2f78693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Fri, 13 May 2022 15:11:26 +0200 Subject: [PATCH] chore: add tests --- .../api/discussions/CreateTest.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/framework/core/tests/integration/api/discussions/CreateTest.php b/framework/core/tests/integration/api/discussions/CreateTest.php index f10db111e..b3ad68f6f 100644 --- a/framework/core/tests/integration/api/discussions/CreateTest.php +++ b/framework/core/tests/integration/api/discussions/CreateTest.php @@ -162,6 +162,38 @@ class CreateTest extends TestCase $this->assertEquals('wo-shi-yi-ge-tu-dou', $discussion->slug); } + /** + * @test + */ + public function can_create_discussion_with_forum_locale_transliteration() + { + // Forum default is traditional Chinese. + $this->app()->getContainer()->make('flarum.settings')->set('default_locale', 'zh'); + // Actor locale is English + $this->app()->getContainer()->make('flarum.locales')->setLocale('en'); + + $response = $this->send( + $this->request('POST', '/api/discussions', [ + 'authenticatedAs' => 1, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'title' => '我是一个土豆', + 'content' => 'predetermined content for automated testing', + ], + ] + ], + ]) + ); + + $this->assertEquals(201, $response->getStatusCode()); + + /** @var Discussion $discussion */ + $discussion = Discussion::firstOrFail(); + + $this->assertEquals('wo-shi-yi-ge-tu-dou', $discussion->slug); + } + /** * @test */