Add test for the GetLink endpoints
This commit is contained in:
parent
4722d74ad8
commit
d0ca2ae497
86
tests/Unit/LodestoneLinkTest.php
Normal file
86
tests/Unit/LodestoneLinkTest.php
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use App\Http\Controllers\LodestoneLinkController;
|
||||||
|
use App\LinkCode;
|
||||||
|
use App\Services\CodeGeneratorService;
|
||||||
|
use App\Services\LodestoneApiService;
|
||||||
|
use App\Services\LodestoneCacheService;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class LodestoneLinkTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
private $lodestoneId = 29778775;
|
||||||
|
private $server = 'Siren';
|
||||||
|
private $name = 'Jisva Fralgo';
|
||||||
|
|
||||||
|
private $websiteName = 'ffxivhelix.com';
|
||||||
|
private $websiteId = 6;
|
||||||
|
|
||||||
|
private $discordGuildId = 618857558740041738;
|
||||||
|
private $discordUserId = 208258599565262848;
|
||||||
|
|
||||||
|
private $lodestoneLinkController;
|
||||||
|
|
||||||
|
protected function setUp(): void {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->lodestoneLinkController = new LodestoneLinkController(
|
||||||
|
new CodeGeneratorService(),
|
||||||
|
new LodestoneCacheService(),
|
||||||
|
new LodestoneApiService()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLinkCodeByDiscordAndId()
|
||||||
|
{
|
||||||
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||||
|
|
||||||
|
$response = $this->lodestoneLinkController->checkDiscordId($this->lodestoneId, $this->discordGuildId, $this->discordUserId);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('link_codes', [
|
||||||
|
'lodestoneId' => $this->lodestoneId,
|
||||||
|
'code' => $response['linkCode']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLinkCodeByDiscordAndName()
|
||||||
|
{
|
||||||
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||||
|
|
||||||
|
$response = $this->lodestoneLinkController->checkDiscordName($this->server, $this->name, $this->discordGuildId, $this->discordUserId);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('link_codes', [
|
||||||
|
'lodestoneId' => $this->lodestoneId,
|
||||||
|
'code' => $response['linkCode']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLinkCodeByWebsiteAndId()
|
||||||
|
{
|
||||||
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||||
|
|
||||||
|
$response = $this->lodestoneLinkController->checkWebsiteId($this->lodestoneId, $this->websiteName, $this->websiteId);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('link_codes', [
|
||||||
|
'lodestoneId' => $this->lodestoneId,
|
||||||
|
'code' => $response['linkCode']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLinkCodeByWebsiteAndName()
|
||||||
|
{
|
||||||
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
||||||
|
|
||||||
|
$response = $this->lodestoneLinkController->checkWebsiteName($this->server, $this->name, $this->websiteName, $this->websiteId);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('link_codes', [
|
||||||
|
'lodestoneId' => $this->lodestoneId,
|
||||||
|
'code' => $response['linkCode']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user