From 5ce437cafe90eeaa24fdd0e1b9191204fcdaecfd Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Mon, 7 Oct 2024 13:41:20 +0200 Subject: [PATCH] test: adjust tests --- .../api/discussions/CreateTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/framework/core/tests/integration/api/discussions/CreateTest.php b/framework/core/tests/integration/api/discussions/CreateTest.php index a8a03e7d28..fc9d894f9b 100644 --- a/framework/core/tests/integration/api/discussions/CreateTest.php +++ b/framework/core/tests/integration/api/discussions/CreateTest.php @@ -9,10 +9,12 @@ namespace Flarum\Tests\integration\api\discussions; +use Flarum\Extend; use Flarum\Discussion\Discussion; use Flarum\Testing\integration\RetrievesAuthorizedUsers; use Flarum\Testing\integration\TestCase; use Illuminate\Support\Arr; +use Flarum\Formatter\Formatter; class CreateTest extends TestCase { @@ -73,6 +75,20 @@ public function cannot_create_discussion_without_content() */ public function cannot_create_discussion_without_content_property() { + $this->extend( + (new Extend\Formatter) + ->unparse(function ($content) { + return $content; + }) + ); + + $this->extend( + (new Extend\Event()) + ->listen(\Flarum\Post\Event\Saving::class, function ($event) { + $event->post->content; + }) + ); + $response = $this->send( $this->request('POST', '/api/discussions', [ 'authenticatedAs' => 1, @@ -107,6 +123,20 @@ public function cannot_create_discussion_without_content_property() */ public function cannot_create_discussion_with_content_set_to_null() { + $this->extend( + (new Extend\Formatter) + ->unparse(function ($content) { + return $content; + }) + ); + + $this->extend( + (new Extend\Event()) + ->listen(\Flarum\Post\Event\Saving::class, function ($event) { + $event->post->content; + }) + ); + $response = $this->send( $this->request('POST', '/api/discussions', [ 'authenticatedAs' => 1,