1
0
Fork 0

TEST: Adding profession import test.

This commit is contained in:
Henrik Hautakoski 2021-07-01 15:24:12 +02:00
parent 6ec98abbbb
commit fecf3a1f00

View file

@ -0,0 +1,128 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\User;
use App\Models\Character;
use App\Models\CharacterProfession;
use App\Models\Profession;
use App\Jobs\ImportProfession;
class ProfessionImportTest extends TestCase
{
use RefreshDatabase;
public function test_import()
{
$this->seed(\Database\Seeders\SettingsSeeders\ItemSeeder::class);
// Profession Exporter v1.1.0 format
$data = (object) [
"server" => "Ashbringer",
"player" => "Superduper",
"guild" => "Nej baba inte tofflan",
"profession" => (object) [
"locale" => "enUS",
"name" => "Alchemy",
"specializationId" => 28672,
"specializationName" => "Transmutation Master",
"level" => 374,
"maxLevel" => 375,
"recipes" => [
(object) [
"name" => "Elixir of Major Defense",
"color" => "ffffff",
"id" => 22834,
"num" => 1,
"categorie" => "Elixir",
"items" => [
(object) [
"color" => "ffffff",
"num" => 3,
"id" => 22790
],
(object) [
"color" => "ffffff",
"num" => 1,
"id" => 22789
],
(object) [
"color" => "ffffff",
"num" => 1,
"id" => 18256
],
],
"spellId" => 28557
],
(object) [
"name" => "Elixir of Major Agility",
"color" => "ffffff",
"id" => 22831,
"num" => 1,
"categorie" => "Elixir",
"items" => [
(object) [
"color" => "ffffff",
"num" => 1,
"id" => 22789
],
(object) [
"color" => "ffffff",
"num" => 2,
"id" => 22785
],
(object) [
"color" => "ffffff",
"num" => 1,
"id" => 18256
]
],
"spellId" => 28553
]
]
]
];
Profession::factory()->create([ 'name' => 'Alchemy' ]);
$character = Character::factory()->create([ 'name' => 'Superduper']);
ImportProfession::dispatch($character, $data);
$this->assertEquals('Alchemy', $character->professions[0]->name);
$recipes = $character->professions[0]->recipes;
// Recipe 1
$this->assertEquals('Elixir of Major Defense', $recipes[0]->craft->name);
$this->assertEquals(18256, $recipes[0]->reagents[0]->external_id);
$this->assertEquals('Imbued Vial', $recipes[0]->reagents[0]->name);
$this->assertEquals(1, $recipes[0]->reagents[0]->quantity);
$this->assertEquals(22789, $recipes[0]->reagents[1]->external_id);
$this->assertEquals('Terocone', $recipes[0]->reagents[1]->name);
$this->assertEquals(1, $recipes[0]->reagents[1]->quantity);
$this->assertEquals(22790, $recipes[0]->reagents[2]->external_id);
$this->assertEquals('Ancient Lichen', $recipes[0]->reagents[2]->name);
$this->assertEquals(3, $recipes[0]->reagents[2]->quantity);
// Recipe 2
$this->assertEquals('Elixir of Major Agility', $recipes[1]->craft->name);
$this->assertEquals(18256, $recipes[1]->reagents[0]->external_id);
$this->assertEquals('Imbued Vial', $recipes[1]->reagents[0]->name);
$this->assertEquals(1, $recipes[1]->reagents[0]->quantity);
$this->assertEquals(22789, $recipes[1]->reagents[1]->external_id);
$this->assertEquals('Terocone', $recipes[1]->reagents[1]->name);
$this->assertEquals(1, $recipes[1]->reagents[1]->quantity);
$this->assertEquals(22785, $recipes[1]->reagents[2]->external_id);
$this->assertEquals('Felweed', $recipes[1]->reagents[2]->name);
$this->assertEquals(2, $recipes[1]->reagents[2]->quantity);
}
}