75 lines
2.3 KiB
PHP
75 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Http\Controllers\LodestoneLinkController;
|
|
use App\LinkCode;
|
|
use App\Services\CodeGeneratorService;
|
|
use App\Services\LodestoneApiService;
|
|
use App\Services\LodestoneCacheService;
|
|
use App\Services\LodestoneLinkingService;
|
|
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 $discordUserId = 208258599565262848;
|
|
|
|
public function testGetLinkCodeByDiscordAndId()
|
|
{
|
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
|
|
|
$response = $this->get('/api/v1/lodestone/link/check/id/'.$this->lodestoneId.'/discord/'.$this->discordUserId);
|
|
|
|
$this->assertDatabaseHas('link_codes', [
|
|
'lodestoneId' => $this->lodestoneId,
|
|
'code' => $response['linkCode']
|
|
]);
|
|
}
|
|
|
|
public function testGetLinkCodeByDiscordAndName()
|
|
{
|
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
|
|
|
$response = $this->get('/api/v1/lodestone/link/check/name/'.$this->server.'/'.$this->name.'/discord/'.$this->discordUserId);
|
|
|
|
$this->assertDatabaseHas('link_codes', [
|
|
'lodestoneId' => $this->lodestoneId,
|
|
'code' => $response['linkCode']
|
|
]);
|
|
}
|
|
|
|
public function testGetLinkCodeByWebsiteAndId()
|
|
{
|
|
LinkCode::where('lodestoneId', $this->lodestoneId)->delete();
|
|
|
|
$response = $this->get('/api/v1/lodestone/link/check/id/'.$this->lodestoneId.'/website/'.$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->get('/api/v1/lodestone/link/check/name/'.$this->server.'/'.$this->name.'/website/'.$this->websiteName.'/'.$this->websiteId);
|
|
|
|
$this->assertDatabaseHas('link_codes', [
|
|
'lodestoneId' => $this->lodestoneId,
|
|
'code' => $response['linkCode']
|
|
]);
|
|
}
|
|
}
|