extension('flarum-suspend'); $this->prepareDatabase([ 'users' => [ ['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1], ['id' => 2, 'username' => 'SuspendedDonny', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1, 'suspended_until' => Carbon::now()->addDay(), 'suspend_reason' => 'acme', 'suspend_message' => 'acme'], ], 'discussions' => [ ['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1], ], 'posts' => [ ['id' => 1, 'number' => 1, 'created_at' => Carbon::now(), 'user_id' => 1, 'discussion_id' => 1, 'content' => '

Hello, world!

'], ] ]); } /** @test */ public function suspended_user_cannot_create_discussions() { $response = $this->send( $this->request('POST', '/api/discussions', [ 'authenticatedAs' => 2, 'json' => [ 'data' => [ 'attributes' => [ 'title' => 'Test post', 'content' => '

Hello, world!

' ], ], ], ]) ); $this->assertEquals(403, $response->getStatusCode()); } /** @test */ public function suspended_user_cannot_reply_to_discussions() { $response = $this->send( $this->request('POST', '/api/posts', [ 'authenticatedAs' => 2, 'json' => [ 'data' => [ 'attributes' => [ 'content' => '

Hello, world!

' ], 'relationships' => [ 'discussion' => [ 'data' => [ 'type' => 'discussions', 'id' => 1, ], ], ], ], ], ]) ); $this->assertEquals(403, $response->getStatusCode()); } }