diff --git a/tests/Feature/ProfessionImport/BasicTest.php b/tests/Feature/ProfessionImport/BasicTest.php index 8110ad0..c98fc34 100644 --- a/tests/Feature/ProfessionImport/BasicTest.php +++ b/tests/Feature/ProfessionImport/BasicTest.php @@ -11,6 +11,9 @@ use App\Models\Recipe; use App\Models\Spell; use App\Jobs\ImportProfession; +use App\ProfessionImport\InvalidCharacterException; +use App\ProfessionImport\InvalidProfessionException; + use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; @@ -136,4 +139,50 @@ class BasicTest extends TestCase $this->assertEquals('Felweed', $recipes[1]->reagents[2]->name); $this->assertEquals(2, $recipes[1]->reagents[2]->quantity); } + + public function test_wrong_character_name() + { + Profession::factory()->create([ 'name' => 'Alchemy' ]); + $character = Character::factory()->create([ 'name' => 'Actualname']); + + $data = (object) [ + "server" => "Ashbringer", + "player" => "Wrongname", + "guild" => "Flat Azeroth Research Team", + "profession" => (object) [ + "name" => "Alchemy", + "level" => 375, + "maxLevel" => 375, + "recipes" => [] + ] + ]; + + $this->expectException(InvalidCharacterException::class); + + ImportProfession::dispatch($character, $data); + } + + public function test_invalid_profession() + { + Profession::factory()->create([ 'name' => 'Alchemy' ]); + Profession::factory()->create([ 'name' => 'Tailoring' ]); + Profession::factory()->create([ 'name' => 'Blacksmith' ]); + $character = Character::factory()->create(); + + $data = (object) [ + "server" => "Ashbringer", + "player" => $character->name, + "guild" => "Futuramalama", + "profession" => (object) [ + "name" => "Carpenter", + "level" => 375, + "maxLevel" => 375, + "recipes" => [] + ] + ]; + + $this->expectException(InvalidProfessionException::class); + + ImportProfession::dispatch($character, $data); + } }