1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +02:00

refactor: remove listing of posts in the show discussion endpoint (#4067)

This commit is contained in:
Sami Mazouz
2024-10-16 18:02:46 +01:00
committed by GitHub
parent 40996de39a
commit b0e8f5ca36
12 changed files with 84 additions and 121 deletions

View File

@@ -88,26 +88,31 @@ class ShowTest extends TestCase
public function guest_cannot_see_hidden_posts()
{
$response = $this->send(
$this->request('GET', '/api/discussions/4')
$this->request('GET', '/api/posts')
->withQueryParams([
'filter' => ['discussion' => 4]
])
);
$json = json_decode($response->getBody()->getContents(), true);
$this->assertEmpty(Arr::get($json, 'data.relationships.posts.data'));
$this->assertEmpty(Arr::get($json, 'data'));
}
#[Test]
public function author_can_see_hidden_posts()
{
$response = $this->send(
$this->request('GET', '/api/discussions/4', [
$this->request('GET', '/api/posts', [
'authenticatedAs' => 2,
])->withQueryParams([
'filter' => ['discussion' => 4]
])
);
$json = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(2, Arr::get($json, 'data.relationships.posts.data.0.id'), $response->getBody()->getContents());
$this->assertEquals(2, Arr::get($json, 'data.0.id'), $response->getBody()->getContents());
}
#[Test]

View File

@@ -59,12 +59,15 @@ class ModelVisibilityTest extends TestCase
);
$response = $this->send(
$this->request('GET', '/api/discussions/2')
$this->request('GET', '/api/posts')
->withQueryParams([
'filter' => ['discussion' => 2]
])
);
$json = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(1, Arr::get($json, 'data.relationships.posts.data.0.id'));
$this->assertEquals(1, Arr::get($json, 'data.0.id'));
}
#[Test]