-
- {{ __('Download this') }}
- {{ __('addon') }}
-
-
-
-
- {{ __('Import string') }}
-
-
-
-
-
-
-
+
+
diff --git a/resources/views/components/profession-import-form.blade.php b/resources/views/components/profession-import-form.blade.php
new file mode 100644
index 0000000..828638b
--- /dev/null
+++ b/resources/views/components/profession-import-form.blade.php
@@ -0,0 +1,17 @@
+
+ {{ __("Important") }}!
+ {{ __('Download this') }}
+ {{ __('addon') }}
+ {{ __('to generate the import string') }}
+
+
+
+
+ {{ __('Import string') }}
+
+
+
+
+
+
+
diff --git a/resources/views/item/show.blade.php b/resources/views/item/show.blade.php
index de1e7c4..4cdd7fb 100644
--- a/resources/views/item/show.blade.php
+++ b/resources/views/item/show.blade.php
@@ -3,6 +3,43 @@
{{ __('Item') }} - {{ $item->name }}
+
+ {{ $item->name }}
+
+ @if (count($item->recipes) > 0)
+
+
+ {{ __('Created by') }}
+
+
+ @foreach($item->recipes as $recipe)
+ -
+ @if ($recipe->spell_id)
+ {{ $recipe->name }}
+ @else
+ {{ $recipe->name }}
+ @endif
+
+ @endforeach
+
+
+ @endif
+
+ @if (count($item->reagent_for) > 0)
+
+
+ {{ __('Reagent for') }}
+
+
+
+ @foreach($item->reagent_for as $recipe)
+
+ @endforeach
+
+
+ @endif
+
+
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index e98d999..95d2f86 100644
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -12,7 +12,7 @@
@if (isset($page_links))
-
+
{{ $page_links }}
@endif
diff --git a/resources/views/profession/create.blade.php b/resources/views/profession/create.blade.php
new file mode 100644
index 0000000..609bac5
--- /dev/null
+++ b/resources/views/profession/create.blade.php
@@ -0,0 +1,13 @@
+
+
+
+
+ {{ __('Import Profession') }}
+
+
+
+
+
+
+
+
diff --git a/resources/views/profile/index.blade.php b/resources/views/profile/index.blade.php
index 49e42b4..e50d6e8 100644
--- a/resources/views/profile/index.blade.php
+++ b/resources/views/profile/index.blade.php
@@ -16,10 +16,14 @@
{{ __('Characters') }}
-
+
{{ __('Add character') }}
+
+
+ {{ __('Import profession') }}
+
diff --git a/resources/views/recipe/show.blade.php b/resources/views/recipe/show.blade.php
index 9518937..aa0f639 100644
--- a/resources/views/recipe/show.blade.php
+++ b/resources/views/recipe/show.blade.php
@@ -9,6 +9,10 @@
+ @if ($recipe->description)
+
{{ $recipe->description }}
+ @endif
+
@if ($recipe->craft)
diff --git a/resources/views/user/show.blade.php b/resources/views/user/show.blade.php
index 9054c06..97eff3f 100644
--- a/resources/views/user/show.blade.php
+++ b/resources/views/user/show.blade.php
@@ -10,12 +10,8 @@
@if ($user->characters->count())
- @if ($user->main_character)
-
- @endif
-
- @foreach($user->alt_characters as $character)
-
+ @foreach($user->characters as $character)
+
@endforeach
@else
diff --git a/routes/web.php b/routes/web.php
index d931034..8993662 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -82,6 +82,12 @@ Route::prefix('items')->name('item.')->group(function () {
// ----------------------------
Route::middleware(['auth'])->group(function() {
+ // Profession
+ Route::prefix('profession')->name('profession.')->group(function() {
+ Route::get('/create', [ProfessionController::class, 'create'])->name('create');
+ Route::post('/', [ProfessionController::class, 'store'])->name('store');
+ });
+
Route::prefix('profile')->name('profile.')->group(function () {
Route::get('/', [ProfileController::class, 'index'])->name('index');
Route::get('/edit', [ProfileController::class, 'edit'])->name('edit');
diff --git a/tests/Feature/ProfessionImport/BasicTest.php b/tests/Feature/ProfessionImport/BasicTest.php
index c98fc34..1f15dd5 100644
--- a/tests/Feature/ProfessionImport/BasicTest.php
+++ b/tests/Feature/ProfessionImport/BasicTest.php
@@ -11,7 +11,6 @@ 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;
@@ -96,7 +95,7 @@ class BasicTest extends TestCase
Profession::factory()->create([ 'name' => 'Alchemy' ]);
$character = Character::factory()->create([ 'name' => 'Superduper']);
- ImportProfession::dispatch($character, $data);
+ ImportProfession::dispatch($data, $character->user, $character);
$this->assertEquals('Alchemy', $character->professions[0]->name);
$recipes = $character->professions[0]->recipes;
@@ -131,35 +130,13 @@ class BasicTest extends TestCase
$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[1]->external_id);
+ $this->assertEquals('Felweed', $recipes[1]->reagents[1]->name);
+ $this->assertEquals(2, $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);
- }
-
- 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);
+ $this->assertEquals(22789, $recipes[1]->reagents[2]->external_id);
+ $this->assertEquals('Terocone', $recipes[1]->reagents[2]->name);
+ $this->assertEquals(1, $recipes[1]->reagents[2]->quantity);
}
public function test_invalid_profession()
@@ -170,7 +147,7 @@ class BasicTest extends TestCase
$character = Character::factory()->create();
$data = (object) [
- "server" => "Ashbringer",
+ "server" => "Sulfuron",
"player" => $character->name,
"guild" => "Futuramalama",
"profession" => (object) [
@@ -183,6 +160,6 @@ class BasicTest extends TestCase
$this->expectException(InvalidProfessionException::class);
- ImportProfession::dispatch($character, $data);
+ ImportProfession::dispatch($data, $character->user, $character);
}
}
diff --git a/tests/Feature/ProfessionImport/CharacterTest.php b/tests/Feature/ProfessionImport/CharacterTest.php
new file mode 100644
index 0000000..93054fa
--- /dev/null
+++ b/tests/Feature/ProfessionImport/CharacterTest.php
@@ -0,0 +1,152 @@
+create([ 'name' => 'Alchemy' ]);
+ $character = Character::factory()->create([ 'name' => 'Charfound']);
+
+ $data = (object) [
+ "server" => "Darkshore",
+ "player" => "Charfound",
+ "guild" => "ABOBA",
+ "profession" => (object) [
+ "name" => "Alchemy",
+ "level" => 375,
+ "maxLevel" => 375,
+ "recipes" => [
+ (object) [
+ "name" => "Elixir of Major Defense",
+ "color" => "ffffff",
+ "id" => 22834,
+ "num" => 1,
+ "categorie" => "Elixir",
+ "items" => [
+ (object) [
+ "name" => "Ancient Lichen",
+ "color" => "ffffff",
+ "num" => 3,
+ "id" => 22790
+ ],
+ (object) [
+ "name" => "Terocone",
+ "color" => "ffffff",
+ "num" => 1,
+ "id" => 22789
+ ],
+ (object) [
+ "name" => "Imbued Vial",
+ "color" => "ffffff",
+ "num" => 1,
+ "id" => 18256
+ ],
+ ],
+ "spellId" => 28557
+ ],
+ ]
+ ]
+ ];
+
+ ImportProfession::dispatch($data, $character->user);
+
+ $this->assertEquals('Alchemy', $character->professions[0]->name);
+ $recipes = $character->professions[0]->recipes;
+
+ $this->assertEquals(22834, $recipes[0]->craft->external_id);
+ $this->assertEquals('Elixir of Major Defense', $recipes[0]->craft->name);
+
+ $this->assertEquals(28557, $recipes[0]->spell->id);
+ $this->assertEquals('Elixir of Major Defense', $recipes[0]->spell->name);
+
+ $this->assertEquals(22790, $recipes[0]->reagents[0]->external_id);
+ $this->assertEquals('Ancient Lichen', $recipes[0]->reagents[0]->name);
+ $this->assertEquals(3, $recipes[0]->reagents[0]->quantity);
+
+ $this->assertEquals(18256, $recipes[0]->reagents[1]->external_id);
+ $this->assertEquals('Imbued Vial', $recipes[0]->reagents[1]->name);
+ $this->assertEquals(1, $recipes[0]->reagents[1]->quantity);
+
+ $this->assertEquals(22789, $recipes[0]->reagents[2]->external_id);
+ $this->assertEquals('Terocone', $recipes[0]->reagents[2]->name);
+ $this->assertEquals(1, $recipes[0]->reagents[2]->quantity);
+ }
+
+ public function test_character_not_found()
+ {
+ $character = Character::factory()->create([ 'name' => 'Findme']);
+
+ $data = (object) [
+ "server" => "Ashbringer",
+ "player" => "Anotherdude",
+ "guild" => "Raiders of the Last Mark",
+ "profession" => (object) [
+ "name" => "Alchemy",
+ "level" => 375,
+ "maxLevel" => 375,
+ "recipes" => []
+ ]
+ ];
+
+ $this->expectException(InvalidCharacterException::class);
+
+ ImportProfession::dispatch($data, $character->user);
+ }
+
+ public function test_other_users_characters_is_not_found()
+ {
+ $character = Character::factory()->create([ 'name' => 'Otherchar']);
+
+ $data = (object) [
+ "server" => "Rattlegore",
+ "player" => "Otherchar",
+ "guild" => "The A-Team",
+ "profession" => (object) [
+ "name" => "Alchemy",
+ "level" => 375,
+ "maxLevel" => 375,
+ "recipes" => []
+ ]
+ ];
+
+ $this->expectException(InvalidCharacterException::class);
+
+ ImportProfession::dispatch($data, User::factory()->create());
+ }
+
+ public function test_character_is_not_the_same_as_imported_name()
+ {
+ $character = Character::factory()->create([ 'name' => 'Actualname']);
+
+ $data = (object) [
+ "server" => "Benediction",
+ "player" => "Wrongname",
+ "guild" => "Spaceballs",
+ "profession" => (object) [
+ "name" => "Alchemy",
+ "level" => 375,
+ "maxLevel" => 375,
+ "recipes" => []
+ ]
+ ];
+
+ $this->expectException(InvalidCharacterException::class);
+
+ ImportProfession::dispatch($data, $character->user, $character);
+ }
+}
diff --git a/tests/Feature/ProfessionImport/RecipesTest.php b/tests/Feature/ProfessionImport/RecipesTest.php
index f958cc0..b9604bd 100644
--- a/tests/Feature/ProfessionImport/RecipesTest.php
+++ b/tests/Feature/ProfessionImport/RecipesTest.php
@@ -22,7 +22,7 @@ class RecipesTest extends TestCase
$this->seed(\Database\Seeders\ProductionSeeders\ItemSeeder::class);
$data = (object) [
- "server" => "Ashbringer",
+ "server" => "Whitemane",
"player" => "Scumbag",
"guild" => "Method",
"profession" => (object) [
@@ -68,7 +68,7 @@ class RecipesTest extends TestCase
Profession::factory()->create([ 'name' => 'Enchanting' ]);
$character = Character::factory()->create([ 'name' => 'Scumbag']);
- ImportProfession::dispatch($character, $data);
+ ImportProfession::dispatch($data, $character->user, $character);
$this->assertEquals('Enchanting', $character->professions[0]->name);
$recipes = $character->professions[0]->recipes;
@@ -106,7 +106,9 @@ class RecipesTest extends TestCase
->create(['spell_id' => null]);
$data = (object) [
+ "server" => "Mograine",
"player" => $character->name,
+ "guild" => "Odyssey",
"profession" => (object) [
"name" => $profession->name,
"level" => 375,
@@ -123,7 +125,7 @@ class RecipesTest extends TestCase
]
];
- ImportProfession::dispatch($character, $data);
+ ImportProfession::dispatch($data, $character->user, $character);
$this->assertEquals(1, Recipe::count());
$this->assertDatabaseHas('recipes', [
diff --git a/tests/Feature/ProfessionImport/SpecializationTest.php b/tests/Feature/ProfessionImport/SpecializationTest.php
index b0b2df8..55d02c9 100644
--- a/tests/Feature/ProfessionImport/SpecializationTest.php
+++ b/tests/Feature/ProfessionImport/SpecializationTest.php
@@ -22,7 +22,9 @@ class SpecializationTest extends TestCase
$specialization = Spell::factory()->create(['id' => 28672, 'name' => 'Transmutation Master']);
$data = (object) [
+ "server" => "Firemaw",
"player" => $character->name,
+ "guild" => "Salad Bakers",
"profession" => (object) [
"name" => $profession->name,
"specializationId" => 28672,
@@ -32,7 +34,7 @@ class SpecializationTest extends TestCase
]
];
- ImportProfession::dispatch($character, $data);
+ ImportProfession::dispatch($data, $character->user, $character);
$this->assertNotNull($character->professions[0]->specialization, "specalization was not imported");
$this->assertEquals(28672, $character->professions[0]->specialization->id);
@@ -47,7 +49,9 @@ class SpecializationTest extends TestCase
$profession = Profession::factory()->create([ 'name' => 'Carpenter' ]);
$data = (object) [
+ "server" => "Loatheb",
"player" => $character->name,
+ "guild" => "Progress",
"profession" => (object) [
"name" => $profession->name,
"level" => 375,
@@ -55,7 +59,7 @@ class SpecializationTest extends TestCase
]
];
- ImportProfession::dispatch($character, $data);
+ ImportProfession::dispatch($data, $character->user, $character);
$this->assertNull($character->professions[0]->specialization);
}
diff --git a/tests/Feature/ProfessionTest.php b/tests/Feature/ProfessionTest.php
new file mode 100644
index 0000000..b70e431
--- /dev/null
+++ b/tests/Feature/ProfessionTest.php
@@ -0,0 +1,89 @@
+get(route('profession.create'));
+
+ $response->assertRedirect(route('auth.login'));
+ }
+
+ public function test_user_is_allowed_to_create_profession()
+ {
+ $user = User::factory()->create();
+
+ $response = $this->actingAs($user)
+ ->get(route('profession.create'));
+
+ $response->assertStatus(200); // OK
+ }
+
+ public function test_user_is_allowed_to_import_profession_for_their_own_character()
+ {
+ Profession::factory()->create(['name' => 'Influencer']);
+ $user = User::factory()->create();
+ $character = Character::factory()
+ ->for($user)
+ ->create(['name' => 'Rambone']);
+
+ $data = '{
+ "server":"Bigglesworth",
+ "player":"Rambone",
+ "guild":"First Blood",
+ "profession": {
+ "locale":"enUS",
+ "name":"Influencer",
+ "specializationId":null,
+ "specializationName":null,
+ "level":375,
+ "maxLevel":375,
+ "recipes": []
+ }
+ }';
+
+ $response = $this->actingAs($user)
+ ->post(route('profession.store'), ['data' => $data]);
+
+ $response->assertSessionHas(['success' => "Profession imported!"]);
+ }
+
+ public function test_user_is_not_allowed_to_import_profession_for_someone_elses_character()
+ {
+ Profession::factory()->create(['name' => 'Alchemy']);
+ $user = User::factory()->create();
+ $character = Character::factory()->create(['name' => 'Angus']);
+
+ $data = '{
+ "server":"Deviate Delight",
+ "player":"Angus",
+ "guild":"Phoenix",
+ "profession": {
+ "locale":"enUS",
+ "name":"Alchemy",
+ "specializationId":null,
+ "specializationName":null,
+ "level":375,
+ "maxLevel":375,
+ "recipes": []
+ }
+ }';
+
+ $response = $this->actingAs($user)
+ ->post(route('profession.store'), ['data' => $data]);
+
+ $response->assertSessionHas(['error' => 'Could not find character "Angus"']);
+ }
+}