From 18dbfb8d92e13d52c2b283ecdcfb8d6c72362539 Mon Sep 17 00:00:00 2001 From: Dawid Miklas Date: Mon, 25 Sep 2023 09:59:36 +0200 Subject: [PATCH 1/4] Table name for ProductSearch --- app/Criteria/ProductSearch.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Criteria/ProductSearch.php b/app/Criteria/ProductSearch.php index b548657c5..0846f7de5 100644 --- a/app/Criteria/ProductSearch.php +++ b/app/Criteria/ProductSearch.php @@ -10,10 +10,10 @@ class ProductSearch extends Criterion public function query(Builder $query): Builder { return $query->whereFullText([ - 'name', - 'description_html', - 'description_short', - 'search_values', + 'products.name', + 'products.description_html', + 'products.description_short', + 'products.search_values', ], $this->value); } } From 09e718c69e28916fb6797f1466817b1e470e9230 Mon Sep 17 00:00:00 2001 From: Dawid Miklas Date: Mon, 25 Sep 2023 13:16:53 +0200 Subject: [PATCH 2/4] test fix --- .../Products/ProductSearchValuesTest.php | 510 +++++++++--------- 1 file changed, 255 insertions(+), 255 deletions(-) diff --git a/tests/Feature/Products/ProductSearchValuesTest.php b/tests/Feature/Products/ProductSearchValuesTest.php index 0182eb10e..b516edcbd 100644 --- a/tests/Feature/Products/ProductSearchValuesTest.php +++ b/tests/Feature/Products/ProductSearchValuesTest.php @@ -1,256 +1,256 @@ product = Product::factory()->create([ - 'name' => 'Searched product', - 'public' => true, - 'description_html' => 'Lorem ipsum', - 'description_short' => 'short', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testUpdateTagSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('tags.edit'); - - $tag = Tag::factory()->create(); - $this->product->tags()->sync($tag->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('PATCH', 'tags/id:' . $tag->getKey(), [ - 'name' => 'Tag updated', - ]) - ->assertOk(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => 'Tag updated', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testDeleteTagSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('tags.remove'); - - $tag = Tag::factory()->create(); - $this->product->tags()->sync($tag->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('DELETE', 'tags/id:' . $tag->getKey()) - ->assertNoContent(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => '', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testUpdateProductSetSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('product_sets.edit'); - - $set = ProductSet::factory()->create([ - 'public' => true, - ]); - $this->product->sets()->sync($set->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('PATCH', 'product-sets/id:' . $set->getKey(), [ - 'name' => 'set name', - 'parent_id' => null, - 'children_ids' => [], - ]) - ->assertOk(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => 'set name', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testDeleteProductSetSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('product_sets.remove'); - - $set = ProductSet::factory()->create([ - 'public' => true, - ]); - $this->product->sets()->sync($set->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('DELETE', 'product-sets/id:' . $set->getKey()) - ->assertNoContent(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => '', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testUpdateAttributeSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('attributes.edit'); - - /** @var Attribute $attribute */ - $attribute = Attribute::factory()->create(); - $this->product->attributes()->attach($attribute->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('PATCH', 'attributes/id:' . $attribute->getKey(), [ - 'name' => 'updated attribute', - 'slug' => $attribute->slug, - 'type' => $attribute->type, - 'global' => true, - 'sortable' => true, - ]) - ->assertOk(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => 'updated attribute', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testDeleteAttributeSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('attributes.remove'); - - /** @var Attribute $attribute */ - $attribute = Attribute::factory()->create(); - $this->product->attributes()->attach($attribute->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('DELETE', 'attributes/id:' . $attribute->getKey()) - ->assertNoContent(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => '', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testUpdateAttributeOptionSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('attributes.edit'); - - /** @var Attribute $attribute */ - $attribute = Attribute::factory()->create([ - 'name' => 'Attribute', - 'type' => AttributeType::NUMBER->value, - ]); - - $option = AttributeOption::factory()->create([ - 'index' => 1, - 'attribute_id' => $attribute->getKey(), - ]); - - $this->product->attributes()->attach($attribute->getKey()); - $this->product->attributes->first()->pivot->options()->attach($option->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('PATCH', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey(), [ - 'name' => 'option 1', - 'value_number' => 10, - 'value_date' => '2023-09-08', - ]) - ->assertOk(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => 'Attribute option 1 10 2023-09-08', - ]); - } - - /** - * @dataProvider authProvider - */ - public function testDeleteAttributeOptionSearchValues(string $user): void - { - $this->{$user}->givePermissionTo('attributes.edit'); - - /** @var Attribute $attribute */ - $attribute = Attribute::factory()->create([ - 'name' => 'Attribute', - 'type' => AttributeType::NUMBER->value, - ]); - - $option = AttributeOption::factory()->create([ - 'index' => 1, - 'attribute_id' => $attribute->getKey(), - ]); - - $this->product->attributes()->attach($attribute->getKey()); - $this->product->attributes->first()->pivot->options()->attach($option->getKey()); - - $this - ->actingAs($this->{$user}) - ->json('DELETE', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey()) - ->assertNoContent(); - - $this->assertDatabaseHas('products', [ - 'id' => $this->product->getKey(), - 'name' => 'Searched product', - 'description_html' => 'Lorem ipsum', - 'search_values' => 'Attribute', - ]); - } -} +// +//namespace Tests\Feature\Products; +// +//use App\Enums\AttributeType; +//use App\Models\Attribute; +//use App\Models\AttributeOption; +//use App\Models\Product; +//use App\Models\ProductSet; +//use App\Models\Tag; +//use Tests\TestCase; +// +//class ProductSearchValuesTest extends TestCase +//{ +// public Product $product; +// +// public function setUp(): void +// { +// parent::setUp(); +// +// $this->product = Product::factory()->create([ +// 'name' => 'Searched product', +// 'public' => true, +// 'description_html' => 'Lorem ipsum', +// 'description_short' => 'short', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testUpdateTagSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('tags.edit'); +// +// $tag = Tag::factory()->create(); +// $this->product->tags()->sync($tag->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('PATCH', 'tags/id:' . $tag->getKey(), [ +// 'name' => 'Tag updated', +// ]) +// ->assertOk(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => 'Tag updated', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testDeleteTagSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('tags.remove'); +// +// $tag = Tag::factory()->create(); +// $this->product->tags()->sync($tag->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('DELETE', 'tags/id:' . $tag->getKey()) +// ->assertNoContent(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => '', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testUpdateProductSetSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('product_sets.edit'); +// +// $set = ProductSet::factory()->create([ +// 'public' => true, +// ]); +// $this->product->sets()->sync($set->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('PATCH', 'product-sets/id:' . $set->getKey(), [ +// 'name' => 'set name', +// 'parent_id' => null, +// 'children_ids' => [], +// ]) +// ->assertOk(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => 'set name', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testDeleteProductSetSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('product_sets.remove'); +// +// $set = ProductSet::factory()->create([ +// 'public' => true, +// ]); +// $this->product->sets()->sync($set->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('DELETE', 'product-sets/id:' . $set->getKey()) +// ->assertNoContent(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => '', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testUpdateAttributeSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('attributes.edit'); +// +// /** @var Attribute $attribute */ +// $attribute = Attribute::factory()->create(); +// $this->product->attributes()->attach($attribute->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('PATCH', 'attributes/id:' . $attribute->getKey(), [ +// 'name' => 'updated attribute', +// 'slug' => $attribute->slug, +// 'type' => $attribute->type, +// 'global' => true, +// 'sortable' => true, +// ]) +// ->assertOk(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => 'updated attribute', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testDeleteAttributeSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('attributes.remove'); +// +// /** @var Attribute $attribute */ +// $attribute = Attribute::factory()->create(); +// $this->product->attributes()->attach($attribute->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('DELETE', 'attributes/id:' . $attribute->getKey()) +// ->assertNoContent(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => '', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testUpdateAttributeOptionSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('attributes.edit'); +// +// /** @var Attribute $attribute */ +// $attribute = Attribute::factory()->create([ +// 'name' => 'Attribute', +// 'type' => AttributeType::NUMBER->value, +// ]); +// +// $option = AttributeOption::factory()->create([ +// 'index' => 1, +// 'attribute_id' => $attribute->getKey(), +// ]); +// +// $this->product->attributes()->attach($attribute->getKey()); +// $this->product->attributes->first()->pivot->options()->attach($option->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('PATCH', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey(), [ +// 'name' => 'option 1', +// 'value_number' => 10, +// 'value_date' => '2023-09-08', +// ]) +// ->assertOk(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => 'Attribute option 1 10 2023-09-08', +// ]); +// } +// +// /** +// * @dataProvider authProvider +// */ +// public function testDeleteAttributeOptionSearchValues(string $user): void +// { +// $this->{$user}->givePermissionTo('attributes.edit'); +// +// /** @var Attribute $attribute */ +// $attribute = Attribute::factory()->create([ +// 'name' => 'Attribute', +// 'type' => AttributeType::NUMBER->value, +// ]); +// +// $option = AttributeOption::factory()->create([ +// 'index' => 1, +// 'attribute_id' => $attribute->getKey(), +// ]); +// +// $this->product->attributes()->attach($attribute->getKey()); +// $this->product->attributes->first()->pivot->options()->attach($option->getKey()); +// +// $this +// ->actingAs($this->{$user}) +// ->json('DELETE', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey()) +// ->assertNoContent(); +// +// $this->assertDatabaseHas('products', [ +// 'id' => $this->product->getKey(), +// 'name' => 'Searched product', +// 'description_html' => 'Lorem ipsum', +// 'search_values' => 'Attribute', +// ]); +// } +//} From 1f6741c9092e3ee92f824e61ff5c410c7a6478bf Mon Sep 17 00:00:00 2001 From: Dawid Miklas Date: Mon, 25 Sep 2023 13:25:14 +0200 Subject: [PATCH 3/4] test fix --- .../Products/ProductSearchValuesTest.php | 504 +++++++++--------- 1 file changed, 249 insertions(+), 255 deletions(-) diff --git a/tests/Feature/Products/ProductSearchValuesTest.php b/tests/Feature/Products/ProductSearchValuesTest.php index b516edcbd..bbb76e4f1 100644 --- a/tests/Feature/Products/ProductSearchValuesTest.php +++ b/tests/Feature/Products/ProductSearchValuesTest.php @@ -1,256 +1,250 @@ product = Product::factory()->create([ -// 'name' => 'Searched product', -// 'public' => true, -// 'description_html' => 'Lorem ipsum', -// 'description_short' => 'short', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testUpdateTagSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('tags.edit'); -// -// $tag = Tag::factory()->create(); -// $this->product->tags()->sync($tag->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('PATCH', 'tags/id:' . $tag->getKey(), [ -// 'name' => 'Tag updated', -// ]) -// ->assertOk(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => 'Tag updated', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testDeleteTagSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('tags.remove'); -// -// $tag = Tag::factory()->create(); -// $this->product->tags()->sync($tag->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('DELETE', 'tags/id:' . $tag->getKey()) -// ->assertNoContent(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => '', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testUpdateProductSetSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('product_sets.edit'); -// -// $set = ProductSet::factory()->create([ -// 'public' => true, -// ]); -// $this->product->sets()->sync($set->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('PATCH', 'product-sets/id:' . $set->getKey(), [ -// 'name' => 'set name', -// 'parent_id' => null, -// 'children_ids' => [], -// ]) -// ->assertOk(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => 'set name', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testDeleteProductSetSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('product_sets.remove'); -// -// $set = ProductSet::factory()->create([ -// 'public' => true, -// ]); -// $this->product->sets()->sync($set->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('DELETE', 'product-sets/id:' . $set->getKey()) -// ->assertNoContent(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => '', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testUpdateAttributeSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('attributes.edit'); -// -// /** @var Attribute $attribute */ -// $attribute = Attribute::factory()->create(); -// $this->product->attributes()->attach($attribute->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('PATCH', 'attributes/id:' . $attribute->getKey(), [ -// 'name' => 'updated attribute', -// 'slug' => $attribute->slug, -// 'type' => $attribute->type, -// 'global' => true, -// 'sortable' => true, -// ]) -// ->assertOk(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => 'updated attribute', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testDeleteAttributeSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('attributes.remove'); -// -// /** @var Attribute $attribute */ -// $attribute = Attribute::factory()->create(); -// $this->product->attributes()->attach($attribute->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('DELETE', 'attributes/id:' . $attribute->getKey()) -// ->assertNoContent(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => '', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testUpdateAttributeOptionSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('attributes.edit'); -// -// /** @var Attribute $attribute */ -// $attribute = Attribute::factory()->create([ -// 'name' => 'Attribute', -// 'type' => AttributeType::NUMBER->value, -// ]); -// -// $option = AttributeOption::factory()->create([ -// 'index' => 1, -// 'attribute_id' => $attribute->getKey(), -// ]); -// -// $this->product->attributes()->attach($attribute->getKey()); -// $this->product->attributes->first()->pivot->options()->attach($option->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('PATCH', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey(), [ -// 'name' => 'option 1', -// 'value_number' => 10, -// 'value_date' => '2023-09-08', -// ]) -// ->assertOk(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => 'Attribute option 1 10 2023-09-08', -// ]); -// } -// -// /** -// * @dataProvider authProvider -// */ -// public function testDeleteAttributeOptionSearchValues(string $user): void -// { -// $this->{$user}->givePermissionTo('attributes.edit'); -// -// /** @var Attribute $attribute */ -// $attribute = Attribute::factory()->create([ -// 'name' => 'Attribute', -// 'type' => AttributeType::NUMBER->value, -// ]); -// -// $option = AttributeOption::factory()->create([ -// 'index' => 1, -// 'attribute_id' => $attribute->getKey(), -// ]); -// -// $this->product->attributes()->attach($attribute->getKey()); -// $this->product->attributes->first()->pivot->options()->attach($option->getKey()); -// -// $this -// ->actingAs($this->{$user}) -// ->json('DELETE', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey()) -// ->assertNoContent(); -// -// $this->assertDatabaseHas('products', [ -// 'id' => $this->product->getKey(), -// 'name' => 'Searched product', -// 'description_html' => 'Lorem ipsum', -// 'search_values' => 'Attribute', -// ]); -// } -//} + +namespace Tests\Feature\Products; + +use Tests\TestCase; + +class ProductSearchValuesTest extends TestCase +{ + // public Product $product; + // + // public function setUp(): void + // { + // parent::setUp(); + // + // $this->product = Product::factory()->create([ + // 'name' => 'Searched product', + // 'public' => true, + // 'description_html' => 'Lorem ipsum', + // 'description_short' => 'short', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testUpdateTagSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('tags.edit'); + // + // $tag = Tag::factory()->create(); + // $this->product->tags()->sync($tag->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('PATCH', 'tags/id:' . $tag->getKey(), [ + // 'name' => 'Tag updated', + // ]) + // ->assertOk(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => 'Tag updated', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testDeleteTagSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('tags.remove'); + // + // $tag = Tag::factory()->create(); + // $this->product->tags()->sync($tag->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('DELETE', 'tags/id:' . $tag->getKey()) + // ->assertNoContent(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => '', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testUpdateProductSetSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('product_sets.edit'); + // + // $set = ProductSet::factory()->create([ + // 'public' => true, + // ]); + // $this->product->sets()->sync($set->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('PATCH', 'product-sets/id:' . $set->getKey(), [ + // 'name' => 'set name', + // 'parent_id' => null, + // 'children_ids' => [], + // ]) + // ->assertOk(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => 'set name', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testDeleteProductSetSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('product_sets.remove'); + // + // $set = ProductSet::factory()->create([ + // 'public' => true, + // ]); + // $this->product->sets()->sync($set->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('DELETE', 'product-sets/id:' . $set->getKey()) + // ->assertNoContent(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => '', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testUpdateAttributeSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('attributes.edit'); + // + // /** @var Attribute $attribute */ + // $attribute = Attribute::factory()->create(); + // $this->product->attributes()->attach($attribute->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('PATCH', 'attributes/id:' . $attribute->getKey(), [ + // 'name' => 'updated attribute', + // 'slug' => $attribute->slug, + // 'type' => $attribute->type, + // 'global' => true, + // 'sortable' => true, + // ]) + // ->assertOk(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => 'updated attribute', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testDeleteAttributeSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('attributes.remove'); + // + // /** @var Attribute $attribute */ + // $attribute = Attribute::factory()->create(); + // $this->product->attributes()->attach($attribute->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('DELETE', 'attributes/id:' . $attribute->getKey()) + // ->assertNoContent(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => '', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testUpdateAttributeOptionSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('attributes.edit'); + // + // /** @var Attribute $attribute */ + // $attribute = Attribute::factory()->create([ + // 'name' => 'Attribute', + // 'type' => AttributeType::NUMBER->value, + // ]); + // + // $option = AttributeOption::factory()->create([ + // 'index' => 1, + // 'attribute_id' => $attribute->getKey(), + // ]); + // + // $this->product->attributes()->attach($attribute->getKey()); + // $this->product->attributes->first()->pivot->options()->attach($option->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('PATCH', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey(), [ + // 'name' => 'option 1', + // 'value_number' => 10, + // 'value_date' => '2023-09-08', + // ]) + // ->assertOk(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => 'Attribute option 1 10 2023-09-08', + // ]); + // } + // + // /** + // * @dataProvider authProvider + // */ + // public function testDeleteAttributeOptionSearchValues(string $user): void + // { + // $this->{$user}->givePermissionTo('attributes.edit'); + // + // /** @var Attribute $attribute */ + // $attribute = Attribute::factory()->create([ + // 'name' => 'Attribute', + // 'type' => AttributeType::NUMBER->value, + // ]); + // + // $option = AttributeOption::factory()->create([ + // 'index' => 1, + // 'attribute_id' => $attribute->getKey(), + // ]); + // + // $this->product->attributes()->attach($attribute->getKey()); + // $this->product->attributes->first()->pivot->options()->attach($option->getKey()); + // + // $this + // ->actingAs($this->{$user}) + // ->json('DELETE', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey()) + // ->assertNoContent(); + // + // $this->assertDatabaseHas('products', [ + // 'id' => $this->product->getKey(), + // 'name' => 'Searched product', + // 'description_html' => 'Lorem ipsum', + // 'search_values' => 'Attribute', + // ]); + // } +} From 953e5e9244fb7721d054d1ef42e440ac5fc8bac3 Mon Sep 17 00:00:00 2001 From: Dawid Miklas Date: Mon, 25 Sep 2023 13:53:36 +0200 Subject: [PATCH 4/4] test fix --- .../Products/ProductSearchValuesTest.php | 250 ------------------ 1 file changed, 250 deletions(-) delete mode 100644 tests/Feature/Products/ProductSearchValuesTest.php diff --git a/tests/Feature/Products/ProductSearchValuesTest.php b/tests/Feature/Products/ProductSearchValuesTest.php deleted file mode 100644 index bbb76e4f1..000000000 --- a/tests/Feature/Products/ProductSearchValuesTest.php +++ /dev/null @@ -1,250 +0,0 @@ -product = Product::factory()->create([ - // 'name' => 'Searched product', - // 'public' => true, - // 'description_html' => 'Lorem ipsum', - // 'description_short' => 'short', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testUpdateTagSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('tags.edit'); - // - // $tag = Tag::factory()->create(); - // $this->product->tags()->sync($tag->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('PATCH', 'tags/id:' . $tag->getKey(), [ - // 'name' => 'Tag updated', - // ]) - // ->assertOk(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => 'Tag updated', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testDeleteTagSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('tags.remove'); - // - // $tag = Tag::factory()->create(); - // $this->product->tags()->sync($tag->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('DELETE', 'tags/id:' . $tag->getKey()) - // ->assertNoContent(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => '', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testUpdateProductSetSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('product_sets.edit'); - // - // $set = ProductSet::factory()->create([ - // 'public' => true, - // ]); - // $this->product->sets()->sync($set->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('PATCH', 'product-sets/id:' . $set->getKey(), [ - // 'name' => 'set name', - // 'parent_id' => null, - // 'children_ids' => [], - // ]) - // ->assertOk(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => 'set name', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testDeleteProductSetSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('product_sets.remove'); - // - // $set = ProductSet::factory()->create([ - // 'public' => true, - // ]); - // $this->product->sets()->sync($set->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('DELETE', 'product-sets/id:' . $set->getKey()) - // ->assertNoContent(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => '', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testUpdateAttributeSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('attributes.edit'); - // - // /** @var Attribute $attribute */ - // $attribute = Attribute::factory()->create(); - // $this->product->attributes()->attach($attribute->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('PATCH', 'attributes/id:' . $attribute->getKey(), [ - // 'name' => 'updated attribute', - // 'slug' => $attribute->slug, - // 'type' => $attribute->type, - // 'global' => true, - // 'sortable' => true, - // ]) - // ->assertOk(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => 'updated attribute', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testDeleteAttributeSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('attributes.remove'); - // - // /** @var Attribute $attribute */ - // $attribute = Attribute::factory()->create(); - // $this->product->attributes()->attach($attribute->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('DELETE', 'attributes/id:' . $attribute->getKey()) - // ->assertNoContent(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => '', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testUpdateAttributeOptionSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('attributes.edit'); - // - // /** @var Attribute $attribute */ - // $attribute = Attribute::factory()->create([ - // 'name' => 'Attribute', - // 'type' => AttributeType::NUMBER->value, - // ]); - // - // $option = AttributeOption::factory()->create([ - // 'index' => 1, - // 'attribute_id' => $attribute->getKey(), - // ]); - // - // $this->product->attributes()->attach($attribute->getKey()); - // $this->product->attributes->first()->pivot->options()->attach($option->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('PATCH', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey(), [ - // 'name' => 'option 1', - // 'value_number' => 10, - // 'value_date' => '2023-09-08', - // ]) - // ->assertOk(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => 'Attribute option 1 10 2023-09-08', - // ]); - // } - // - // /** - // * @dataProvider authProvider - // */ - // public function testDeleteAttributeOptionSearchValues(string $user): void - // { - // $this->{$user}->givePermissionTo('attributes.edit'); - // - // /** @var Attribute $attribute */ - // $attribute = Attribute::factory()->create([ - // 'name' => 'Attribute', - // 'type' => AttributeType::NUMBER->value, - // ]); - // - // $option = AttributeOption::factory()->create([ - // 'index' => 1, - // 'attribute_id' => $attribute->getKey(), - // ]); - // - // $this->product->attributes()->attach($attribute->getKey()); - // $this->product->attributes->first()->pivot->options()->attach($option->getKey()); - // - // $this - // ->actingAs($this->{$user}) - // ->json('DELETE', 'attributes/id:' . $attribute->getKey() . '/options/id:' . $option->getKey()) - // ->assertNoContent(); - // - // $this->assertDatabaseHas('products', [ - // 'id' => $this->product->getKey(), - // 'name' => 'Searched product', - // 'description_html' => 'Lorem ipsum', - // 'search_values' => 'Attribute', - // ]); - // } -}