1
0
mirror of https://github.com/flarum/core.git synced 2025-07-30 21:20:24 +02:00

feat: include current user as forum relation (#3668)

* feat: include current user as forum relation

* Update framework/core/src/Api/Controller/ShowForumController.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

* Update framework/core/src/Api/Controller/ShowForumController.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

* Update framework/core/src/Api/Serializer/ForumSerializer.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

* Update framework/core/tests/integration/api/forum/ShowTest.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

* Update framework/core/tests/integration/api/forum/ShowTest.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

* No need to call the user endpoint as we already have the data loaded

* chore: return types

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
IanM
2022-11-25 11:00:19 +00:00
committed by GitHub
parent 6f4f964ce8
commit 67c0d75ebc
4 changed files with 39 additions and 40 deletions

View File

@@ -31,6 +31,22 @@ class ShowTest extends TestCase
]);
}
/**
* @test
*/
public function guest_user_does_not_see_actor_relationship()
{
$response = $this->send(
$this->request('GET', '/api')
);
$this->assertEquals(200, $response->getStatusCode());
$json = json_decode($response->getBody()->getContents(), true);
$this->assertArrayNotHasKey('actor', Arr::get($json, 'data.relationships'));
}
/**
* @test
*/
@@ -51,6 +67,8 @@ class ShowTest extends TestCase
$this->assertEquals('http://localhost/api', Arr::get($json, 'data.attributes.apiUrl'));
$this->assertArrayNotHasKey('adminUrl', Arr::get($json, 'data.attributes'));
$this->assertArrayHasKey('actor', Arr::get($json, 'data.relationships'));
$this->assertEquals(2, Arr::get($json, 'data.relationships.actor.data.id'));
}
/**