test: refactor profession import tests into multiple classes.
This commit is contained in:
parent
ee6e2d8925
commit
88995dab35
4 changed files with 335 additions and 299 deletions
139
tests/Feature/ProfessionImport/BasicTest.php
Normal file
139
tests/Feature/ProfessionImport/BasicTest.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\ProfessionImport;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Character;
|
||||
use App\Models\CharacterProfession;
|
||||
use App\Models\Profession;
|
||||
use App\Models\Item;
|
||||
use App\Models\Recipe;
|
||||
use App\Models\Spell;
|
||||
use App\Jobs\ImportProfession;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BasicTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_import()
|
||||
{
|
||||
$this->seed(\Database\Seeders\ProductionSeeders\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(22834, $recipes[0]->craft->external_id);
|
||||
$this->assertEquals('Elixir of Major Defense', $recipes[0]->craft->name);
|
||||
|
||||
$this->assertEquals(28557, $recipes[0]->spell->id);
|
||||
$this->assertEquals('Elixir of Major Defense', $recipes[0]->spell->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(22831, $recipes[1]->craft->external_id);
|
||||
$this->assertEquals('Elixir of Major Agility', $recipes[1]->craft->name);
|
||||
|
||||
$this->assertEquals(28553, $recipes[1]->spell->id);
|
||||
$this->assertEquals('Elixir of Major Agility', $recipes[1]->spell->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);
|
||||
}
|
||||
}
|
||||
134
tests/Feature/ProfessionImport/RecipesTest.php
Normal file
134
tests/Feature/ProfessionImport/RecipesTest.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\ProfessionImport;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Character;
|
||||
use App\Models\Profession;
|
||||
use App\Models\Item;
|
||||
use App\Models\Recipe;
|
||||
use App\Jobs\ImportProfession;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RecipesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_import_recipe_without_craft_item()
|
||||
{
|
||||
$this->seed(\Database\Seeders\ProductionSeeders\ItemSeeder::class);
|
||||
|
||||
$data = (object) [
|
||||
"server" => "Ashbringer",
|
||||
"player" => "Scumbag",
|
||||
"guild" => "Method",
|
||||
"profession" => (object) [
|
||||
"locale" => "enUS",
|
||||
"name" => "Enchanting",
|
||||
"specializationId" => null,
|
||||
"specializationName" => null,
|
||||
"level" => 303,
|
||||
"maxLevel" => 375,
|
||||
"recipes" => [
|
||||
(object) [
|
||||
"description" => "Permanently enchant boots to give +7 Agility.",
|
||||
"name" => "Enchant Boots - Greater Agility",
|
||||
"num" => 0,
|
||||
"categorie" => "none",
|
||||
"items" => [
|
||||
(object) [
|
||||
"color" => "1eff00",
|
||||
"id" => 16203,
|
||||
"num" => 8
|
||||
]
|
||||
],
|
||||
"spellId" => 20023
|
||||
],
|
||||
(object) [
|
||||
"description" => "Transforms a Nexus Crystal into a Small Prismatic Shard.",
|
||||
"name" => "Nexus Transformation",
|
||||
"num" => 1,
|
||||
"categorie" => "none",
|
||||
"items" => [
|
||||
(object) [
|
||||
"color" => "a335ee",
|
||||
"id" => 20725,
|
||||
"num" => 1
|
||||
]
|
||||
],
|
||||
"spellId" => 42613
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
Profession::factory()->create([ 'name' => 'Enchanting' ]);
|
||||
$character = Character::factory()->create([ 'name' => 'Scumbag']);
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertEquals('Enchanting', $character->professions[0]->name);
|
||||
$recipes = $character->professions[0]->recipes;
|
||||
|
||||
// Recipe 1
|
||||
$this->assertNull($recipes[0]->craft);
|
||||
|
||||
$this->assertEquals(20023, $recipes[0]->spell->id);
|
||||
$this->assertEquals('Enchant Boots - Greater Agility', $recipes[0]->spell->name);
|
||||
|
||||
$this->assertEquals(16203, $recipes[0]->reagents[0]->external_id);
|
||||
$this->assertEquals('Greater Eternal Essence', $recipes[0]->reagents[0]->name);
|
||||
$this->assertEquals(8, $recipes[0]->reagents[0]->quantity);
|
||||
|
||||
// Recipe 2
|
||||
$this->assertNull($recipes[1]->craft);
|
||||
|
||||
$this->assertEquals(42613, $recipes[1]->spell->id);
|
||||
$this->assertEquals('Nexus Transformation', $recipes[1]->spell->name);
|
||||
|
||||
$this->assertEquals(20725, $recipes[1]->reagents[0]->external_id);
|
||||
$this->assertEquals('Nexus Crystal', $recipes[1]->reagents[0]->name);
|
||||
$this->assertEquals(1, $recipes[1]->reagents[0]->quantity);
|
||||
}
|
||||
|
||||
public function test_import_does_not_create_duplicate_recipes_if_spell_relationship_is_missing()
|
||||
{
|
||||
$character = Character::factory()->create([ 'name' => 'Duplicated']);
|
||||
$profession = Profession::factory()->create([ 'name' => 'My Unique Profession' ]);
|
||||
$item = Item::factory()->create(['name' => 'Unique Recipe']);
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($profession)
|
||||
->for($item, 'craft')
|
||||
->create(['spell_id' => null]);
|
||||
|
||||
$data = (object) [
|
||||
"player" => $character->name,
|
||||
"profession" => (object) [
|
||||
"name" => $profession->name,
|
||||
"level" => 375,
|
||||
"maxLevel" => 375,
|
||||
"recipes" => [
|
||||
(object) [
|
||||
"name" => $item->name,
|
||||
"num" => 0,
|
||||
"categorie" => "none",
|
||||
"items" => [],
|
||||
"spellId" => 1337
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertEquals(1, Recipe::count());
|
||||
$this->assertDatabaseHas('recipes', [
|
||||
'spell_id' => 1337,
|
||||
'item_id' => $item->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
62
tests/Feature/ProfessionImport/SpecializationTest.php
Normal file
62
tests/Feature/ProfessionImport/SpecializationTest.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\ProfessionImport;
|
||||
|
||||
use App\Models\Character;
|
||||
use App\Models\Profession;
|
||||
use App\Models\Spell;
|
||||
use App\Jobs\ImportProfession;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SpecializationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_specialization_is_imported_correctly()
|
||||
{
|
||||
$character = Character::factory()->create([ 'name' => 'Specialdude']);
|
||||
$profession = Profession::factory()->create([ 'name' => 'Alchemy' ]);
|
||||
$specialization = Spell::factory()->create(['id' => 28672, 'name' => 'Transmutation Master']);
|
||||
|
||||
$data = (object) [
|
||||
"player" => $character->name,
|
||||
"profession" => (object) [
|
||||
"name" => $profession->name,
|
||||
"specializationId" => 28672,
|
||||
"specializationName" => "Transmutation Master",
|
||||
"level" => 375,
|
||||
"recipes" => [],
|
||||
]
|
||||
];
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertNotNull($character->professions[0]->specialization, "specalization was not imported");
|
||||
$this->assertEquals(28672, $character->professions[0]->specialization->id);
|
||||
$this->assertEquals("Transmutation Master", $character->professions[0]->specialization->name);
|
||||
|
||||
$this->assertEquals(1, Spell::count());
|
||||
}
|
||||
|
||||
public function test_specialization_can_be_omitted()
|
||||
{
|
||||
$character = Character::factory()->create([ 'name' => 'frankthetank']);
|
||||
$profession = Profession::factory()->create([ 'name' => 'Carpenter' ]);
|
||||
|
||||
$data = (object) [
|
||||
"player" => $character->name,
|
||||
"profession" => (object) [
|
||||
"name" => $profession->name,
|
||||
"level" => 375,
|
||||
"recipes" => [],
|
||||
]
|
||||
];
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertNull($character->professions[0]->specialization);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,299 +0,0 @@
|
|||
<?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\Models\Item;
|
||||
use App\Models\Recipe;
|
||||
use App\Models\Spell;
|
||||
use App\Jobs\ImportProfession;
|
||||
|
||||
class ProfessionImportTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_import()
|
||||
{
|
||||
$this->seed(\Database\Seeders\ProductionSeeders\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(22834, $recipes[0]->craft->external_id);
|
||||
$this->assertEquals('Elixir of Major Defense', $recipes[0]->craft->name);
|
||||
|
||||
$this->assertEquals(28557, $recipes[0]->spell->id);
|
||||
$this->assertEquals('Elixir of Major Defense', $recipes[0]->spell->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(22831, $recipes[1]->craft->external_id);
|
||||
$this->assertEquals('Elixir of Major Agility', $recipes[1]->craft->name);
|
||||
|
||||
$this->assertEquals(28553, $recipes[1]->spell->id);
|
||||
$this->assertEquals('Elixir of Major Agility', $recipes[1]->spell->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);
|
||||
}
|
||||
|
||||
public function test_import_recipe_without_craft_item()
|
||||
{
|
||||
$this->seed(\Database\Seeders\ProductionSeeders\ItemSeeder::class);
|
||||
|
||||
$data = (object) [
|
||||
"server" => "Ashbringer",
|
||||
"player" => "Scumbag",
|
||||
"guild" => "Method",
|
||||
"profession" => (object) [
|
||||
"locale" => "enUS",
|
||||
"name" => "Enchanting",
|
||||
"specializationId" => null,
|
||||
"specializationName" => null,
|
||||
"level" => 303,
|
||||
"maxLevel" => 375,
|
||||
"recipes" => [
|
||||
(object) [
|
||||
"description" => "Permanently enchant boots to give +7 Agility.",
|
||||
"name" => "Enchant Boots - Greater Agility",
|
||||
"num" => 0,
|
||||
"categorie" => "none",
|
||||
"items" => [
|
||||
(object) [
|
||||
"color" => "1eff00",
|
||||
"id" => 16203,
|
||||
"num" => 8
|
||||
]
|
||||
],
|
||||
"spellId" => 20023
|
||||
],
|
||||
(object) [
|
||||
"description" => "Transforms a Nexus Crystal into a Small Prismatic Shard.",
|
||||
"name" => "Nexus Transformation",
|
||||
"num" => 1,
|
||||
"categorie" => "none",
|
||||
"items" => [
|
||||
(object) [
|
||||
"color" => "a335ee",
|
||||
"id" => 20725,
|
||||
"num" => 1
|
||||
]
|
||||
],
|
||||
"spellId" => 42613
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
Profession::factory()->create([ 'name' => 'Enchanting' ]);
|
||||
$character = Character::factory()->create([ 'name' => 'Scumbag']);
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertEquals('Enchanting', $character->professions[0]->name);
|
||||
$recipes = $character->professions[0]->recipes;
|
||||
|
||||
// Recipe 1
|
||||
$this->assertNull($recipes[0]->craft);
|
||||
|
||||
$this->assertEquals(20023, $recipes[0]->spell->id);
|
||||
$this->assertEquals('Enchant Boots - Greater Agility', $recipes[0]->spell->name);
|
||||
|
||||
$this->assertEquals(16203, $recipes[0]->reagents[0]->external_id);
|
||||
$this->assertEquals('Greater Eternal Essence', $recipes[0]->reagents[0]->name);
|
||||
$this->assertEquals(8, $recipes[0]->reagents[0]->quantity);
|
||||
|
||||
// Recipe 2
|
||||
$this->assertNull($recipes[1]->craft);
|
||||
|
||||
$this->assertEquals(42613, $recipes[1]->spell->id);
|
||||
$this->assertEquals('Nexus Transformation', $recipes[1]->spell->name);
|
||||
|
||||
$this->assertEquals(20725, $recipes[1]->reagents[0]->external_id);
|
||||
$this->assertEquals('Nexus Crystal', $recipes[1]->reagents[0]->name);
|
||||
$this->assertEquals(1, $recipes[1]->reagents[0]->quantity);
|
||||
}
|
||||
|
||||
public function test_import_does_not_create_duplicate_recipes_if_spell_relationship_is_missing()
|
||||
{
|
||||
$character = Character::factory()->create([ 'name' => 'Duplicated']);
|
||||
$profession = Profession::factory()->create([ 'name' => 'My Unique Profession' ]);
|
||||
$item = Item::factory()->create(['name' => 'Unique Recipe']);
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($profession)
|
||||
->for($item, 'craft')
|
||||
->create(['spell_id' => null]);
|
||||
|
||||
$data = (object) [
|
||||
"player" => $character->name,
|
||||
"profession" => (object) [
|
||||
"name" => $profession->name,
|
||||
"level" => 375,
|
||||
"maxLevel" => 375,
|
||||
"recipes" => [
|
||||
(object) [
|
||||
"name" => $item->name,
|
||||
"num" => 0,
|
||||
"categorie" => "none",
|
||||
"items" => [],
|
||||
"spellId" => 1337
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertEquals(1, Recipe::count());
|
||||
$this->assertDatabaseHas('recipes', [
|
||||
'spell_id' => 1337,
|
||||
'item_id' => $item->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_specialization_is_imported_correctly()
|
||||
{
|
||||
$character = Character::factory()->create([ 'name' => 'Specialdude']);
|
||||
$profession = Profession::factory()->create([ 'name' => 'Alchemy' ]);
|
||||
$specialization = Spell::factory()->create(['id' => 28672, 'name' => 'Transmutation Master']);
|
||||
|
||||
$data = (object) [
|
||||
"player" => $character->name,
|
||||
"profession" => (object) [
|
||||
"name" => $profession->name,
|
||||
"specializationId" => 28672,
|
||||
"specializationName" => "Transmutation Master",
|
||||
"level" => 375,
|
||||
"recipes" => [],
|
||||
]
|
||||
];
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertNotNull($character->professions[0]->specialization, "specalization was not imported");
|
||||
$this->assertEquals(28672, $character->professions[0]->specialization->id);
|
||||
$this->assertEquals("Transmutation Master", $character->professions[0]->specialization->name);
|
||||
|
||||
$this->assertEquals(1, Spell::count());
|
||||
}
|
||||
|
||||
public function test_specialization_can_be_omitted()
|
||||
{
|
||||
$character = Character::factory()->create([ 'name' => 'frankthetank']);
|
||||
$profession = Profession::factory()->create([ 'name' => 'Carpenter' ]);
|
||||
|
||||
$data = (object) [
|
||||
"player" => $character->name,
|
||||
"profession" => (object) [
|
||||
"name" => $profession->name,
|
||||
"level" => 375,
|
||||
"recipes" => [],
|
||||
]
|
||||
];
|
||||
|
||||
ImportProfession::dispatch($character, $data);
|
||||
|
||||
$this->assertNull($character->professions[0]->specialization);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue