1
0
Fork 0

tests/Feature/ProfessionImportTest.php: test recipe without item.

This commit is contained in:
Henrik Hautakoski 2021-07-08 07:30:47 +02:00
parent f50227ec19
commit cc3e0584b5

View file

@ -133,4 +133,81 @@ class ProfessionImportTest extends TestCase
$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);
}
}