Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: flarum 2.0 upgrade #108

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
SychO9 committed Aug 2, 2024
commit 4b3b30f43c44ec9c5b0ad8a544e815185be8f8c4
18 changes: 12 additions & 6 deletions tests/integration/api/BestAnswerTest.php
Original file line number Diff line number Diff line change
@@ -114,9 +114,13 @@ public function setting_best_answer_increases_author_best_answer_count()
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => 2,
'bestAnswerUserId' => 1,
'relationships' => [
'bestAnswerPost' => [
'data' => [
'type' => 'posts',
'id' => 2
]
],
],
],

@@ -126,7 +130,7 @@ public function setting_best_answer_increases_author_best_answer_count()
)
);

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(200, $response->getStatusCode(), $response->getBody()->getContents());

$discussion = Discussion::find(1);

@@ -149,8 +153,10 @@ public function unsetting_best_answer_decreases_author_best_answer_count()
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => 0,
'relationships' => [
'bestAnswerPost' => [
'data' => null
],
],
],

15 changes: 11 additions & 4 deletions tests/integration/api/SetBestAnswerTest.php
Original file line number Diff line number Diff line change
@@ -94,8 +94,13 @@ public function setBestAnswer(int $userId, int $postId): ResponseInterface
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => $postId,
'relationships' => [
'bestAnswerPost' => [
'data' => [
'type' => 'posts',
'id' => $postId
],
],
],
],
],
@@ -125,9 +130,11 @@ public function user_with_permission_can_set_best_answer(int $userId)

$response = $this->setBestAnswer($userId, 3);

$this->assertEquals(200, $response->getStatusCode());
$contents = $response->getBody()->getContents();

$data = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(200, $response->getStatusCode(), $contents);

$data = json_decode($contents, true);

$attributes = $data['data']['attributes'];

33 changes: 23 additions & 10 deletions tests/integration/api/UnsetBestAnswerTest.php
Original file line number Diff line number Diff line change
@@ -93,8 +93,10 @@ public function user_can_unset_best_answer_in_own_discussion_and_select_a_differ
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => 0,
'relationships' => [
'bestAnswerPost' => [
'data' => null
],
],
],

@@ -130,8 +132,13 @@ public function user_can_unset_best_answer_in_own_discussion_and_select_a_differ
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => 3,
'relationships' => [
'bestAnswerPost' => [
'data' => [
'type' => 'posts',
'id' => 3,
]
],
],
],

@@ -141,9 +148,11 @@ public function user_can_unset_best_answer_in_own_discussion_and_select_a_differ
)
);

$this->assertEquals(200, $response->getStatusCode());
$contents = $response->getBody()->getContents();

$data = json_decode($response->getBody()->getContents(), true);
$this->assertEquals(200, $response->getStatusCode(), $contents);

$data = json_decode($contents, true);

$attributes = $data['data']['attributes'];
$this->assertEquals(3, $attributes['hasBestAnswer'], 'Expected best answer post ID to be 3');
@@ -178,8 +187,10 @@ public function user_without_permission_cannot_unset_a_best_answer(int $userId)
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => 0,
'relationships' => [
'bestAnswerPost' => [
'data' => null
],
],
],

@@ -206,8 +217,10 @@ public function user_with_permission_can_unset_a_best_answer(int $userId)
[
'json' => [
'data' => [
'attributes' => [
'bestAnswerPostId' => 0,
'relationships' => [
'bestAnswerPost' => [
'data' => null
],
],
],

136 changes: 0 additions & 136 deletions tests/unit/SaveBestAnswerToDatabaseTest.php

This file was deleted.