-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix creating product options values in hub (#1402)
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...min/tests/Unit/Http/Livewire/Components/Settings/Product/ProductOptionValueCreateTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Lunar\Hub\Tests\Unit\Http\Livewire\Components\Settings\Product; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Livewire\Livewire; | ||
use Lunar\Hub\Http\Livewire\Components\Settings\Product\Options\OptionEdit; | ||
use Lunar\Hub\Models\Staff; | ||
use Lunar\Hub\Tests\TestCase; | ||
use Lunar\Models\Language; | ||
use Lunar\Models\ProductOption; | ||
use Lunar\Models\ProductOptionValue; | ||
|
||
class ProductOptionValueCreateTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Language::factory()->create([ | ||
'default' => true, | ||
'code' => 'en', | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
* */ | ||
public function can_populate_product_option_data() | ||
{ | ||
ProductOption::factory(1)->create()->each(function ($option) { | ||
$staff = Staff::factory()->create([ | ||
'admin' => true, | ||
]); | ||
|
||
LiveWire::actingAs($staff, 'staff') | ||
->test(OptionEdit::class, ['productOption' => $option]) | ||
->set('newProductOptionValue.name.' . Language::getDefault()->code, 'Size') | ||
->call('createOptionValue'); | ||
|
||
$this->assertDatabaseHas((new ProductOptionValue())->getTable(), [ | ||
'product_option_id' => $option->id, | ||
'name' => json_encode([Language::getDefault()->code => 'Size']) | ||
]); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters