tests/Feature/ProfessionImport/BasicTest.php: Test exceptions.
This commit is contained in:
parent
0edb50c2ad
commit
d25a0aa94f
1 changed files with 49 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue