initial commit
This commit is contained in:
commit
1e1aa7d461
215 changed files with 35140 additions and 0 deletions
22
tests/CreatesApplication.php
Normal file
22
tests/CreatesApplication.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
54
tests/Feature/AuthenticationTest.php
Normal file
54
tests/Feature/AuthenticationTest.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AuthenticationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_login_screen_can_be_rendered()
|
||||
{
|
||||
$response = $this->get(route('auth.login'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_users_can_authenticate_using_the_login_screen()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->post(route('auth.login.store'), [
|
||||
'username' => $user->username,
|
||||
'password' => 'password',
|
||||
]);
|
||||
|
||||
$this->assertAuthenticated();
|
||||
$response->assertRedirect('/');
|
||||
}
|
||||
|
||||
public function test_users_can_not_authenticate_with_invalid_password()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->post(route('auth.login.store'), [
|
||||
'username' => $user->username,
|
||||
'password' => 'wrong-password',
|
||||
]);
|
||||
|
||||
$this->assertGuest();
|
||||
}
|
||||
|
||||
public function test_user_can_logout()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)->delete(route('auth.logout'));
|
||||
|
||||
$this->assertGuest();
|
||||
}
|
||||
}
|
||||
92
tests/Feature/CharacterCreateTest.php
Normal file
92
tests/Feature/CharacterCreateTest.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Character;
|
||||
|
||||
use App\Http\Livewire\Form\CreateCharacterForm;
|
||||
|
||||
class CharacterCreateTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_can_render_character_creation_page()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get(route('character.create'));
|
||||
|
||||
$response->assertStatus(200); // OK
|
||||
}
|
||||
|
||||
public function test_guest_can_not_render_character_creation_page()
|
||||
{
|
||||
$response = $this->get(route('character.create'));
|
||||
|
||||
$response->assertStatus(403); // Forbidden
|
||||
}
|
||||
|
||||
public function test_user_can_create_characters()
|
||||
{
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
\Livewire::test(CreateCharacterForm::class)
|
||||
->set('name', 'Elise')
|
||||
->set('level', '70')
|
||||
->set('class', 'warrior')
|
||||
->set('race', 'human')
|
||||
->set('gender', 'F')
|
||||
->call('save')
|
||||
->assertRedirect(route('user.index'));
|
||||
|
||||
// Find character and check the data.
|
||||
$character = Character::where('name', 'Elise')->first();
|
||||
|
||||
$this->assertEquals(70, $character->level);
|
||||
$this->assertEquals('warrior', $character->class);
|
||||
$this->assertEquals('human', $character->race);
|
||||
$this->assertEquals('F', $character->gender);
|
||||
}
|
||||
|
||||
public function test_user_can_not_create_alot_of_characters()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
// Create "alot" of characters (8 or so is the limit in the front-end).
|
||||
Character::factory()
|
||||
->for($user)
|
||||
->count(20)->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
// Try create one more via livewire form.
|
||||
\Livewire::test(CreateCharacterForm::class)
|
||||
->set('name', 'Notonemore')
|
||||
->set('level', '10')
|
||||
->set('class', 'mage')
|
||||
->set('race', 'troll')
|
||||
->set('gender', 'M')
|
||||
->call('save')
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_guest_can_not_create_characters()
|
||||
{
|
||||
\Livewire::test(CreateCharacterForm::class)
|
||||
->set('name', 'Guestchar')
|
||||
->set('level', '61')
|
||||
->set('class', 'priest')
|
||||
->set('race', 'dwarf')
|
||||
->set('gender', 'M')
|
||||
->call('save')
|
||||
->assertForbidden();
|
||||
|
||||
$this->assertDatabaseMissing('characters', [ 'name' => 'Guestchar' ]);
|
||||
}
|
||||
}
|
||||
53
tests/Feature/CharacterDestroyTest.php
Normal file
53
tests/Feature/CharacterDestroyTest.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Character;
|
||||
|
||||
class CharacterDestroyTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_can_delete_their_own_character()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$character = Character::factory()->for($user)->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->delete(route('character.destroy', [ 'character' => $character ]));
|
||||
|
||||
$response->assertStatus(302); // Redirect
|
||||
|
||||
$this->assertDatabaseMissing('characters', [ 'id' => $character->id ]);
|
||||
}
|
||||
|
||||
public function test_guest_can_not_delete_character()
|
||||
{
|
||||
$character = Character::factory()->create();
|
||||
|
||||
$response = $this->delete(route('character.destroy', [ 'character' => $character ]));
|
||||
|
||||
$response->assertStatus(403); // Not allowed
|
||||
|
||||
$this->assertDatabaseHas('characters', [ 'id' => $character->id ]);
|
||||
}
|
||||
|
||||
public function test_user_can_not_delete_someone_elses_character()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$userOther = User::factory()->create();
|
||||
$character = Character::factory()->for($userOther)->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->delete(route('character.destroy', [ 'character' => $character ]));
|
||||
|
||||
$response->assertStatus(403); // Not allowed
|
||||
|
||||
$this->assertDatabaseHas('characters', [ 'id' => $character->id ]);
|
||||
}
|
||||
}
|
||||
84
tests/Feature/CharacterProfessionTest.php
Normal file
84
tests/Feature/CharacterProfessionTest.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Character;
|
||||
use App\Models\CharacterProfession;
|
||||
use App\Models\Profession;
|
||||
|
||||
class CharacterProfessionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_is_allowed_to_create_profession_for_their_own_character()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$character = Character::factory()
|
||||
->for($user)
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get(route('character.profession.create', [ 'character' => $character ]));
|
||||
|
||||
$response->assertStatus(200); // OK
|
||||
}
|
||||
|
||||
public function test_user_is_not_allowed_to_create_profession_for_someone_elses_character()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$character = Character::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get(route('character.profession.create', [ 'character' => $character ]));
|
||||
|
||||
$response->assertStatus(403); // Not allowed
|
||||
}
|
||||
|
||||
public function test_user_is_allowed_to_delete_profession_from_their_own_character()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$profession = Profession::factory()->create();
|
||||
$character = Character::factory()
|
||||
->for($user)
|
||||
->create();
|
||||
|
||||
$ch_prof = CharacterProfession::factory()
|
||||
->for($character)
|
||||
->for($profession)
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->delete(route('character.profession.destroy', [ 'character' => $character, 'profession' => $profession ]));
|
||||
|
||||
// The response should be a redirect in this case.
|
||||
$response->assertStatus(302);
|
||||
|
||||
// Check that the character profession is deleted.
|
||||
$this->assertDatabaseMissing('character_professions', [ 'id' => $ch_prof->id ]);
|
||||
}
|
||||
|
||||
public function test_user_is_not_allowed_to_delete_profession_from_someone_elses_character()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$profession = Profession::factory()->create();
|
||||
$character = Character::factory()->create();
|
||||
|
||||
$ch_prof = CharacterProfession::factory()
|
||||
->for($character)
|
||||
->for($profession)
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->delete(route('character.profession.destroy', [ 'character' => $character, 'profession' => $profession ]));
|
||||
|
||||
$response->assertStatus(403); // Not allowed
|
||||
|
||||
// Check that the character profession is still there.
|
||||
$this->assertDatabaseHas('character_professions', [ 'id' => $ch_prof->id ]);
|
||||
}
|
||||
}
|
||||
52
tests/Feature/Models/CharacterTest.php
Normal file
52
tests/Feature/Models/CharacterTest.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\CharacterProfession;
|
||||
use App\Models\Character;
|
||||
|
||||
class CharacterTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Test user relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_user_relationship()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$character = Character::factory()
|
||||
->for($user)
|
||||
->create();
|
||||
|
||||
$this->assertEquals($user->id, $character->user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test character profession relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_profession_relationship()
|
||||
{
|
||||
$this->seed(\Database\Seeders\SettingsSeeders\ProfessionsTableSeeder::class);
|
||||
|
||||
$professions = CharacterProfession::factory(2)->create();
|
||||
$character = Character::factory()->create();
|
||||
|
||||
$character->professions()->save($professions[0]);
|
||||
$character->professions()->save($professions[1]);
|
||||
|
||||
$this->assertEquals(2, $character->professions->count());
|
||||
|
||||
foreach($professions as $profession) {
|
||||
$this->assertContains($profession->id, $character->professions->pluck('id')->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
55
tests/Feature/Models/ItemTest.php
Normal file
55
tests/Feature/Models/ItemTest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\Recipe;
|
||||
use App\Models\Item;
|
||||
|
||||
class ItemTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Test recipe relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_recipe_relationship()
|
||||
{
|
||||
$item = Item::factory()->create();
|
||||
$recipe = Recipe::factory()
|
||||
->for($item, 'craft')
|
||||
->create();
|
||||
|
||||
$this->assertEquals($recipe->id, $item->recipe->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test quantity attribute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_quantity_attribute()
|
||||
{
|
||||
$recipe = Recipe::factory()->create();
|
||||
$item = Item::factory()->create();
|
||||
$recipe->reagents()->attach($item, ['quantity' => 5]);
|
||||
|
||||
$this->assertEquals(5, $recipe->reagents[0]->quantity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test quantity attribute missing
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_quantity_attribute_missing()
|
||||
{
|
||||
$item = Item::factory()->create();
|
||||
|
||||
$this->assertNull($item->quantity);
|
||||
}
|
||||
}
|
||||
144
tests/Feature/Models/RecipeTest.php
Normal file
144
tests/Feature/Models/RecipeTest.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\Recipe;
|
||||
use App\Models\RecipeCategory;
|
||||
use App\Models\Profession;
|
||||
use App\Models\CharacterProfession;
|
||||
use App\Models\Character;
|
||||
use App\Models\Item;
|
||||
|
||||
class RecipeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Test profession relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_profession_relationship()
|
||||
{
|
||||
$profession = Profession::factory()->create();
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($profession)
|
||||
->create();
|
||||
|
||||
$this->assertEquals($profession->id, $recipe->profession->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test category relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_category_relationship()
|
||||
{
|
||||
$category = RecipeCategory::factory()->create();
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($category, 'category')
|
||||
->create();
|
||||
|
||||
$this->assertEquals($category->id, $recipe->category->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test craft relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_craft_relationship()
|
||||
{
|
||||
$item = Item::factory()->create();
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($item, 'craft')
|
||||
->create();
|
||||
|
||||
$this->assertEquals($item->id, $recipe->craft->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test character profession relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_character_profession_relationship()
|
||||
{
|
||||
$profession = Profession::factory()->create();
|
||||
$ch_profs = CharacterProfession::factory(2)->create([ 'profession_id' => $profession->id ]);
|
||||
$characters = Character::factory(2)->create();
|
||||
|
||||
$characters[0]->professions()->save($ch_profs[0]);
|
||||
$characters[1]->professions()->save($ch_profs[1]);
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($profession)
|
||||
->create();
|
||||
|
||||
$characters[0]->professions[0]->recipes()->save($recipe);
|
||||
$characters[1]->professions[0]->recipes()->save($recipe);
|
||||
|
||||
$professions = $recipe->character_profession;
|
||||
|
||||
$this->assertEquals($ch_profs[0]->id, $professions[0]->id);
|
||||
$this->assertEquals($ch_profs[1]->id, $professions[1]->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test crafters relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_crafters_relationship()
|
||||
{
|
||||
$profession = Profession::factory()->create();
|
||||
$ch_profs = CharacterProfession::factory(2)->create([ 'profession_id' => $profession->id ]);
|
||||
$characters = Character::factory(2)->create();
|
||||
|
||||
$characters[0]->professions()->save($ch_profs[0]);
|
||||
$characters[1]->professions()->save($ch_profs[1]);
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($profession)
|
||||
->create();
|
||||
|
||||
// Make both character learn the recipe.
|
||||
$characters[0]->professions[0]->learn($recipe);
|
||||
$characters[1]->professions[0]->learn($recipe);
|
||||
|
||||
$crafters = $recipe->crafters;
|
||||
|
||||
$this->assertEquals($crafters[0]->id, $characters[0]->id);
|
||||
$this->assertEquals($crafters[1]->id, $characters[1]->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test reagants relationship.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_reagents_relationship()
|
||||
{
|
||||
$profession = Profession::factory()->create();
|
||||
$items = Item::factory(3)->create();
|
||||
|
||||
$recipe = Recipe::factory()
|
||||
->for($profession)
|
||||
->create();
|
||||
|
||||
$recipe->reagents()->attach($items[0], ['quantity' => 1]);
|
||||
$recipe->reagents()->attach($items[1], ['quantity' => 4]);
|
||||
$recipe->reagents()->attach($items[2], ['quantity' => 10]);
|
||||
|
||||
$this->assertEquals($items[0]->id, $recipe->reagents[0]->id);
|
||||
$this->assertEquals($items[1]->id, $recipe->reagents[1]->id);
|
||||
$this->assertEquals($items[2]->id, $recipe->reagents[2]->id);
|
||||
}
|
||||
}
|
||||
55
tests/Feature/UserTest.php
Normal file
55
tests/Feature/UserTest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_can_view_profile()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get(route('user.index'));
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_guest_can_not_view_profile()
|
||||
{
|
||||
$response = $this->get(route('user.index'));
|
||||
|
||||
$response->assertRedirect(route('auth.login'));
|
||||
}
|
||||
|
||||
public function test_user_can_update()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->post(route('user.update'), [
|
||||
'current_password' => 'password',
|
||||
'password' => 'newpassword',
|
||||
'password_confirmation' => 'newpassword'
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('user.index'));
|
||||
}
|
||||
|
||||
public function test_guest_can_not_update()
|
||||
{
|
||||
$response = $this->post(route('user.update'), [
|
||||
'current_password' => 'password',
|
||||
'password' => 'newpassword',
|
||||
'password_confirmation' => 'newpassword'
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('auth.login'));
|
||||
}
|
||||
}
|
||||
10
tests/TestCase.php
Normal file
10
tests/TestCase.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
}
|
||||
165
tests/Unit/Warcraft/ClassesTest.php
Normal file
165
tests/Unit/Warcraft/ClassesTest.php
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Warcraft;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use App\Warcraft\Races;
|
||||
use App\Warcraft\Classes;
|
||||
|
||||
class ClassesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_all()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::PALADIN => 'Paladin',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::SHAMAN => 'Shaman',
|
||||
Classes::MAGE => 'Mage',
|
||||
Classes::WARLOCK => 'Warlock',
|
||||
Classes::DRUID => 'Druid'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_human()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::PALADIN => 'Paladin',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::MAGE => 'Mage',
|
||||
Classes::WARLOCK => 'Warlock'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::HUMAN)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_dwarf()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::PALADIN => 'Paladin',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::DWARF)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_gnome()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::MAGE => 'Mage',
|
||||
Classes::WARLOCK => 'Warlock'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::GNOME)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_night_elf()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::DRUID => 'Druid'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::NIGHTELF)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_draenei()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::PALADIN => 'Paladin',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::SHAMAN => 'Shaman',
|
||||
Classes::MAGE => 'Mage'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::DRAENEI)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_orc()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::SHAMAN => 'Shaman',
|
||||
Classes::WARLOCK => 'Warlock'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::ORC)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_troll()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::SHAMAN => 'Shaman',
|
||||
Classes::MAGE => 'Mage'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::TROLL)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_tauren()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::SHAMAN => 'Shaman',
|
||||
Classes::DRUID => 'Druid'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::TAUREN)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_undead()
|
||||
{
|
||||
$expected = [
|
||||
Classes::WARRIOR => 'Warrior',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::MAGE => 'Mage',
|
||||
Classes::WARLOCK => 'Warlock'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::UNDEAD)->toArray());
|
||||
}
|
||||
|
||||
public function test_classes_for_blood_elf()
|
||||
{
|
||||
$expected = [
|
||||
Classes::PALADIN => 'Paladin',
|
||||
Classes::HUNTER => 'Hunter',
|
||||
Classes::ROGUE => 'Rogue',
|
||||
Classes::PRIEST => 'Priest',
|
||||
Classes::MAGE => 'Mage',
|
||||
Classes::WARLOCK => 'Warlock'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Classes)->race(Races::BLOODELF)->toArray());
|
||||
}
|
||||
}
|
||||
184
tests/Unit/Warcraft/RacesTest.php
Normal file
184
tests/Unit/Warcraft/RacesTest.php
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Warcraft;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use App\Warcraft\Races;
|
||||
use App\Warcraft\Classes;
|
||||
|
||||
class RacesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_all()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::GNOME => 'Gnome',
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::DRAENEI => 'Draenei',
|
||||
Races::ORC => 'Orc',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::TAUREN => 'Tauren',
|
||||
Races::UNDEAD => 'Undead',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->toArray());
|
||||
}
|
||||
|
||||
public function test_only_alliance()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::GNOME => 'Gnome',
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::DRAENEI => 'Draenei',
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->alliance()->toArray());
|
||||
}
|
||||
|
||||
public function test_only_horde()
|
||||
{
|
||||
$expected = [
|
||||
Races::ORC => 'Orc',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::TAUREN => 'Tauren',
|
||||
Races::UNDEAD => 'Undead',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->horde()->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_warrior()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::GNOME => 'Gnome',
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::DRAENEI => 'Draenei',
|
||||
Races::ORC => 'Orc',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::TAUREN => 'Tauren',
|
||||
Races::UNDEAD => 'Undead',
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::WARRIOR)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_paladin()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::DRAENEI => 'Draenei',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::PALADIN)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_hunter()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::DRAENEI => 'Draenei',
|
||||
Races::ORC => 'Orc',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::TAUREN => 'Tauren',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::HUNTER)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_rogue()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::GNOME => 'Gnome',
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::ORC => 'Orc',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::UNDEAD => 'Undead',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::ROGUE)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_priest()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::DWARF => 'Dwarf',
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::DRAENEI => 'Draenei',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::UNDEAD => 'Undead',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::PRIEST)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_shaman()
|
||||
{
|
||||
$expected = [
|
||||
Races::DRAENEI => 'Draenei',
|
||||
Races::ORC => 'Orc',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::TAUREN => 'Tauren'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::SHAMAN)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_mage()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::GNOME => 'Gnome',
|
||||
Races::TROLL => 'Troll',
|
||||
Races::UNDEAD => 'Undead',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::MAGE)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_warlock()
|
||||
{
|
||||
$expected = [
|
||||
Races::HUMAN => 'Human',
|
||||
Races::GNOME => 'Gnome',
|
||||
Races::ORC => 'Orc',
|
||||
Races::UNDEAD => 'Undead',
|
||||
Races::BLOODELF => 'Blood elf'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::WARLOCK)->toArray());
|
||||
}
|
||||
|
||||
public function test_can_be_druid()
|
||||
{
|
||||
$expected = [
|
||||
Races::NIGHTELF => 'Night elf',
|
||||
Races::TAUREN => 'Tauren'
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, (new Races)->class(Classes::DRUID)->toArray());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue