Skip to content

Commit

Permalink
test: adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 7, 2024
1 parent 3ea9f97 commit 5ce437c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions framework/core/tests/integration/api/discussions/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5ce437c

Please sign in to comment.