diff --git a/tests/Unit/LodestoneLinkTest.php b/tests/Unit/LodestoneLinkTest.php new file mode 100644 index 0000000..4097343 --- /dev/null +++ b/tests/Unit/LodestoneLinkTest.php @@ -0,0 +1,86 @@ +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'] + ]); + } +}