Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
faced319c5
|
@ -5,11 +5,8 @@
|
||||||
colors="true"
|
colors="true"
|
||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Unit">
|
<testsuite name="Tests">
|
||||||
<directory suffix="Test.php">./tests/Unit</directory>
|
<directory suffix="Test.php">tests</directory>
|
||||||
</testsuite>
|
|
||||||
<testsuite name="Feature">
|
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<coverage processUncoveredFiles="true">
|
<coverage processUncoveredFiles="true">
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
use App\Models\DiscordUser;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class ApiVerifyDiscordTest extends TestCase
|
|
||||||
{
|
|
||||||
use RefreshDatabase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A basic feature test example.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function test_verify_without_params()
|
|
||||||
{
|
|
||||||
$this->postJson('/api/verify')->assertStatus(422);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_verify_with_invalid_user_id()
|
|
||||||
{
|
|
||||||
$this->postJson('/api/verify', [
|
|
||||||
'user_id' => rand(10000000, 100000000)
|
|
||||||
])->assertStatus(422)->assertJsonValidationErrors('user_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_verify_with_valid_discord_user_id_but_with_invalid_user_id()
|
|
||||||
{
|
|
||||||
$discordUser = DiscordUser::factory()->create([
|
|
||||||
'user_id' => 9999999999999
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->postJson('/api/verify', [
|
|
||||||
'user_id' => $discordUser->id
|
|
||||||
])->assertStatus(422)->assertJsonValidationErrors('user_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_verify_with_valid_discord_user_id_with_valid_user_id()
|
|
||||||
{
|
|
||||||
$discordUser = DiscordUser::factory()->create();
|
|
||||||
|
|
||||||
$this->postJson('/api/verify', [
|
|
||||||
'user_id' => $discordUser->id
|
|
||||||
])->assertStatus(200);
|
|
||||||
|
|
||||||
$this->assertEquals((250 + 375), User::find($discordUser->user->id)->credits);
|
|
||||||
$this->assertEquals(3, User::find($discordUser->user->id)->server_limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_verify_second_time_should_not_work()
|
|
||||||
{
|
|
||||||
$discordUser = DiscordUser::factory()->create();
|
|
||||||
|
|
||||||
$this->postJson('/api/verify', [
|
|
||||||
'user_id' => $discordUser->id
|
|
||||||
])->assertStatus(200);
|
|
||||||
|
|
||||||
$this->postJson('/api/verify', [
|
|
||||||
'user_id' => $discordUser->id
|
|
||||||
])->assertStatus(422)->assertJsonValidationErrors('user_id');
|
|
||||||
|
|
||||||
$this->assertEquals((250 + 375), User::find($discordUser->user->id)->credits);
|
|
||||||
$this->assertEquals(3, User::find($discordUser->user->id)->server_limit);
|
|
||||||
}
|
|
||||||
}
|
|
14
tests/Unit/exampleTest.php
Normal file
14
tests/Unit/exampleTest.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class exampleTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_example(): void
|
||||||
|
{
|
||||||
|
$response = $this->get('/');
|
||||||
|
$response->assertStatus(302);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue