From fecf3a1f0020516766096d5d5a67f310fb7e52b6 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 1 Jul 2021 15:24:12 +0200 Subject: [PATCH] TEST: Adding profession import test. --- tests/Feature/ProfessionImportTest.php | 128 +++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 tests/Feature/ProfessionImportTest.php diff --git a/tests/Feature/ProfessionImportTest.php b/tests/Feature/ProfessionImportTest.php new file mode 100644 index 0000000..d61bbb2 --- /dev/null +++ b/tests/Feature/ProfessionImportTest.php @@ -0,0 +1,128 @@ +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); + } +}