mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-02-22 20:59:46 -06:00
tests: Improve several tests
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Tests\Feature\Http\Controllers\API;
|
||||
|
||||
use App\Models\Bot;
|
||||
use App\Models\Chatroom;
|
||||
use App\Models\ChatStatus;
|
||||
use App\Models\Message;
|
||||
use App\Models\User;
|
||||
use App\Models\UserAudible;
|
||||
@@ -34,7 +35,9 @@ class ChatControllerTest extends TestCase
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson(['data' => [[
|
||||
'id' => $userAudible['user_id'],
|
||||
'id' => $userAudible->id,
|
||||
'user_id' => $userAudible->user_id,
|
||||
'user' => ['id' => $userAudible->user_id],
|
||||
]]]);
|
||||
}
|
||||
|
||||
@@ -230,11 +233,18 @@ class ChatControllerTest extends TestCase
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('api/chat/messages/{room_id}');
|
||||
$message = factory(Message::class)->create();
|
||||
|
||||
$response->assertOk();
|
||||
$response = $this->actingAs($user)->get(sprintf('api/chat/messages/%s', $message['chatroom_id']));
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson(['data' => [[
|
||||
'id' => $message->id,
|
||||
'bot' => ['id' => $message['bot_id']],
|
||||
'user' => ['id' => $message['user_id']],
|
||||
'receiver' => ['id' => $message['receiver_id']],
|
||||
'chatroom' => ['id' => $message['chatroom_id']],
|
||||
]]]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -242,35 +252,62 @@ class ChatControllerTest extends TestCase
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('api/chat/private/messages/{target_id}');
|
||||
$message = factory(Message::class)->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
$response = $this->actingAs($user)->get(sprintf('api/chat/private/messages/%s', $message['receiver_id']));
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson(['data' => [[
|
||||
'id' => $message->id,
|
||||
'bot' => ['id' => $message['bot_id']],
|
||||
'user' => ['id' => $message['user_id']],
|
||||
'receiver' => ['id' => $message['receiver_id']],
|
||||
'chatroom' => ['id' => $message['chatroom_id']],
|
||||
]]]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function rooms_returns_an_ok_response()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test fails on Travis-CI, despite passing everywhere else, so skipping until the cause is determined.'
|
||||
);
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('api/chat/rooms');
|
||||
|
||||
$response->assertOk();
|
||||
$chatroom = Chatroom::findOrFail($user->chatroom_id);
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson(['data' => [[
|
||||
'id' => $chatroom->id,
|
||||
'name' => $chatroom->name,
|
||||
]]]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function statuses_returns_an_ok_response()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test fails on Travis-CI, despite passing everywhere else, so skipping until the cause is determined.'
|
||||
);
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('api/chat/statuses');
|
||||
|
||||
$response->assertOk();
|
||||
$chatStatus = ChatStatus::findOrFail($user->chat_status_id);
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson([[
|
||||
'id' => $chatStatus->id,
|
||||
'name' => $chatStatus->name,
|
||||
'color' => $chatStatus->color,
|
||||
'icon' => $chatStatus->icon,
|
||||
]]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -286,9 +323,11 @@ class ChatControllerTest extends TestCase
|
||||
'bot_id' => $userAudible['bot_id'],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -304,62 +343,85 @@ class ChatControllerTest extends TestCase
|
||||
'room_id' => $userAudible['room_id'],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function toggle_target_audible_returns_an_ok_response()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('api/chat/audibles/{user_id}/toggle/target', [
|
||||
// TODO: send request data
|
||||
$userAudible = factory(UserAudible::class)->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
$response = $this->actingAs($user)->post(sprintf('api/chat/audibles/%s/toggle/target', $user->id), [
|
||||
'target_id' => $userAudible['target_id'],
|
||||
]);
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function update_user_chat_status_returns_an_ok_response()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test fails on Travis-CI, despite passing everywhere else, so skipping until the cause is determined.'
|
||||
);
|
||||
|
||||
$this->seed(UsersTableSeeder::class);
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('api/chat/user/{id}/status', [
|
||||
// TODO: send request data
|
||||
$response = $this->actingAs($user)->post(sprintf('api/chat/user/%s/status', $user->id), [
|
||||
'status_id' => $user['chat_status_id'],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function update_user_room_returns_an_ok_response()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test fails on Travis-CI, despite passing everywhere else, so skipping until the cause is determined.'
|
||||
);
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('api/chat/user/{id}/chatroom', [
|
||||
// TODO: send request data
|
||||
$response = $this->actingAs($user)->post(sprintf('api/chat/user/%s/chatroom', $user->id), [
|
||||
'room_id' => $user['chatroom_id'],
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
// TODO: perform additional assertions
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function update_user_target_returns_an_ok_response()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('api/chat/user/{id}/target', [
|
||||
// TODO: send request data
|
||||
$response = $this->actingAs($user)->post(sprintf('api/chat/user/%s/target', $user->id));
|
||||
|
||||
$response->assertOk()->assertJson([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
]);
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
// TODO: perform additional assertions
|
||||
}
|
||||
|
||||
// test cases...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user