Skip to content

Commit 73b8ca4

Browse files
fix: feature test bug
1 parent 1486790 commit 73b8ca4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

app/Livewire/Pages/Collection/CollectionProducts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace App\Livewire\Pages\Collection;
66

7-
use App\Models\Collection;
87
use App\Models\Product;
98
use Illuminate\Contracts\View\View;
109
use Livewire\Component;
10+
use Shopper\Core\Models\Collection;
1111

1212
class CollectionProducts extends Component
1313
{

app/Livewire/Pages/Store.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function render(): View
2626
->latest();
2727

2828
if (count($this->selectedAttributes) > 0) {
29-
$query = $query->whereHas('attributes', function ($query) {
29+
$query = $query->whereHas('options', function ($query) {
3030
$query->whereIn('attribute_value_id', $this->selectedAttributes);
3131
});
3232
}

tests/Feature/Livewire/Pages/StoreTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@
3232

3333
it('can filters products', function () {
3434
$colorAttribute = Attribute::query()->create(['name' => 'Color', 'slug' => 'color', 'type' => 'checkbox']);
35+
$this->assertNotNull($colorAttribute->id);
36+
3537
$redAttributeValue = AttributeValue::query()->create(['value' => 'Red', 'key' => '#1e3a8a', 'attribute_id' => $colorAttribute->id]);
3638
$blueAttributeValue = AttributeValue::query()->create(['value' => 'Blue', 'key' => '#ddf048', 'attribute_id' => $colorAttribute->id]);
39+
3740
$sizeAttribute = Attribute::query()->create(['name' => 'Size', 'slug' => 'size', 'type' => 'checkbox']);
41+
42+
$this->assertNotNull($sizeAttribute->id);
43+
3844
$smallAttributeValue = AttributeValue::query()->create(['value' => 'Small', 'key' => 'XL', 'attribute_id' => $sizeAttribute->id]);
3945
$largeAttributeValue = AttributeValue::query()->create(['value' => 'Large', 'key' => 'L', 'attribute_id' => $sizeAttribute->id]);
4046

41-
$this->product->attributes()->createMany([
47+
$this->product->options()->attach([
4248
['attribute_value_id' => $redAttributeValue->id, 'attribute_id' => $colorAttribute->id],
4349
['attribute_value_id' => $smallAttributeValue->id, 'attribute_id' => $sizeAttribute->id],
4450
]);
4551

46-
$this->secondProduct->attributes()->createMany([
52+
$this->secondProduct->options()->attach([
4753
['attribute_value_id' => $blueAttributeValue->id, 'attribute_id' => $colorAttribute->id],
4854
['attribute_value_id' => $largeAttributeValue->id, 'attribute_id' => $sizeAttribute->id],
4955
]);

0 commit comments

Comments
 (0)