From cc3e0584b5cf6092d525c83dc3a3593370a6d59d Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 8 Jul 2021 07:30:47 +0200 Subject: [PATCH] tests/Feature/ProfessionImportTest.php: test recipe without item. --- tests/Feature/ProfessionImportTest.php | 77 ++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/Feature/ProfessionImportTest.php b/tests/Feature/ProfessionImportTest.php index f334e93..dcbe1cf 100644 --- a/tests/Feature/ProfessionImportTest.php +++ b/tests/Feature/ProfessionImportTest.php @@ -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); + } }