From 3fcb93fda751966e1903300e68637be2fdeabd66 Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Thu, 16 Jan 2020 13:57:03 +0100 Subject: [PATCH 01/30] add docker-compose-collection to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index fa1eccb1e..00fbc0be4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/docker-compose-collection +/bin /node_modules /public/hot /public/storage From 132dd6c0f0ef466f7e726350667e032df450d7ee Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Fri, 17 Jan 2020 14:42:47 +0100 Subject: [PATCH 02/30] introduce guest checkout configuration --- package.json | 10 +- packages/Webkul/Admin/src/Config/system.php | 13 +- .../Admin/src/Resources/lang/en/app.php | 3 + .../views/catalog/products/edit.blade.php | 4 + .../views/configuration/index.blade.php | 5 + .../Seeders/AttributeFamilyTableSeeder.php | 6 +- .../Seeders/AttributeGroupTableSeeder.php | 16 +- .../Seeders/AttributeOptionTableSeeder.php | 3 +- .../Database/Seeders/AttributeTableSeeder.php | 14 +- .../src/Database/Seeders/DatabaseSeeder.php | 4 +- .../Database/Seeders/CMSPagesTableSeeder.php | 5 +- packages/Webkul/Checkout/src/Models/Cart.php | 20 +- .../Database/Seeders/ConfigTableSeeder.php | 27 ++ .../src/Database/Seeders/DatabaseSeeder.php | 1 + .../Core/src/Helpers/Laravel5Helper.php | 115 ++++++++ .../Factories/InventorySourceFactory.php | 27 ++ .../ProductAttributeValueFactory.php | 261 ++++++++++++++++++ .../src/Database/Factories/ProductFactory.php | 23 ++ .../Factories/ProductInventoryFactory.php | 20 ++ .../src/Providers/ProductServiceProvider.php | 30 +- .../Webkul/Product/src/Type/Downloadable.php | 16 +- .../Http/Controllers/OnepageController.php | 11 +- tests/_support/AcceptanceTester.php | 16 ++ tests/_support/FunctionalTester.php | 23 ++ tests/acceptance.suite.yml | 24 +- tests/acceptance/GuestCheckoutCest.php | 59 ++++ tests/functional.suite.yml | 4 +- tests/functional/Product/ProductCest.php | 2 +- tests/functional/Shop/GuestCheckoutCest.php | 90 ++++++ 29 files changed, 812 insertions(+), 40 deletions(-) create mode 100644 packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php create mode 100644 packages/Webkul/Core/src/Helpers/Laravel5Helper.php create mode 100644 packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php create mode 100644 packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php create mode 100644 packages/Webkul/Product/src/Database/Factories/ProductFactory.php create mode 100644 packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php create mode 100644 tests/acceptance/GuestCheckoutCest.php create mode 100644 tests/functional/Shop/GuestCheckoutCest.php diff --git a/package.json b/package.json index 88cbe757f..103d618f3 100755 --- a/package.json +++ b/package.json @@ -13,12 +13,16 @@ "devDependencies": { "axios": "^0.18", "bootstrap": "^4.0.0", - "popper.js": "^1.12", "cross-env": "^5.1", "jquery": "^3.2", - "laravel-mix": "^2.0", + "laravel-mix": "^5.0.1", "lodash": "^4.17.4", - "vue": "^2.5.7" + "popper.js": "^1.12", + "resolve-url-loader": "^3.1.0", + "sass": "^1.24.5", + "sass-loader": "^8.0.2", + "vue": "^2.5.7", + "vue-template-compiler": "^2.6.11" }, "dependencies": { "opencollective-postinstall": "^2.0.1", diff --git a/packages/Webkul/Admin/src/Config/system.php b/packages/Webkul/Admin/src/Config/system.php index d9a39ee19..39148ce20 100644 --- a/packages/Webkul/Admin/src/Config/system.php +++ b/packages/Webkul/Admin/src/Config/system.php @@ -87,10 +87,21 @@ return [ 'key' => 'catalog.products', 'name' => 'admin::app.admin.system.products', 'sort' => 2 + ], [ + 'key' => 'catalog.products.guest-checkout', + 'name' => 'admin::app.admin.system.guest-checkout', + 'sort' => 1, + 'fields' => [ + [ + 'name' => 'allow-guest-checkout', + 'title' => 'admin::app.admin.system.allow-guest-checkout', + 'type' => 'boolean' + ] + ] ], [ 'key' => 'catalog.products.review', 'name' => 'admin::app.admin.system.review', - 'sort' => 1, + 'sort' => 2, 'fields' => [ [ 'name' => 'guest_review', diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 71aa08dac..adae4ecc7 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -1202,6 +1202,9 @@ return [ 'system' => [ 'catalog' => 'Catalog', 'products' => 'Products', + 'guest-checkout' => 'Guest Checkout', + 'allow-guest-checkout' => 'Allow Guest Checkout', + 'allow-guest-checkout-hint' => 'Hint: If turned on, this option can be configured for each product specifically.', 'review' => 'Review', 'allow-guest-review' => 'Allow Guest Review', 'inventory' => 'Inventory', diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php index e76ff2035..6adba4afc 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php @@ -77,6 +77,10 @@ @foreach ($customAttributes as $attribute) code == 'guest_checkout' && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { + continue; + } + $validations = []; if ($attribute->is_required) { diff --git a/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php b/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php index cf1de3a02..a8b39c936 100755 --- a/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php @@ -65,6 +65,11 @@ @include ('admin::configuration.field-type', ['field' => $field]) + @php ($hint = $field['title'] . '-hint') + @if ($hint !== __($hint)) + {{ __($hint) }} + @endif + @endforeach diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php index c93bec117..9926ecd3d 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php @@ -3,16 +3,20 @@ namespace Webkul\Attribute\Database\Seeders; use Illuminate\Database\Seeder; -use DB; +use Illuminate\Support\Facades\DB; class AttributeFamilyTableSeeder extends Seeder { public function run() { + DB::statement('SET FOREIGN_KEY_CHECKS=0;'); + DB::table('attribute_families')->delete(); DB::table('attribute_families')->insert([ ['id' => '1','code' => 'default','name' => 'Default','status' => '0','is_user_defined' => '1'] ]); + + DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php index 92fa5db6c..394c5ac48 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php @@ -3,12 +3,17 @@ namespace Webkul\Attribute\Database\Seeders; use Illuminate\Database\Seeder; -use DB; +use Illuminate\Support\Facades\DB; class AttributeGroupTableSeeder extends Seeder { public function run() { + DB::statement('SET FOREIGN_KEY_CHECKS=0;'); + + DB::table('attribute_groups')->delete(); + DB::table('attribute_group_mappings')->delete(); + DB::table('attribute_groups')->delete(); DB::table('attribute_groups')->insert([ @@ -42,9 +47,12 @@ class AttributeGroupTableSeeder extends Seeder ['attribute_id' => '20','attribute_group_id' => '5','position' => '2'], ['attribute_id' => '21','attribute_group_id' => '5','position' => '3'], ['attribute_id' => '22','attribute_group_id' => '5','position' => '4'], - ['attribute_id' => '23','attribute_group_id' => '1','position' => '9'], - ['attribute_id' => '24','attribute_group_id' => '1','position' => '10'], - ['attribute_id' => '25','attribute_group_id' => '1','position' => '11'] + ['attribute_id' => '23','attribute_group_id' => '1','position' => '10'], + ['attribute_id' => '24','attribute_group_id' => '1','position' => '11'], + ['attribute_id' => '25','attribute_group_id' => '1','position' => '12'], + ['attribute_id' => '26','attribute_group_id' => '1','position' => '9'] ]); + + DB::statement('SET FOREIGN_KEY_CHECKS=0;'); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php index 992c625c0..5bdc0ba9e 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php @@ -3,7 +3,7 @@ namespace Webkul\Attribute\Database\Seeders; use Illuminate\Database\Seeder; -use DB; +use Illuminate\Support\Facades\DB; class AttributeOptionTableSeeder extends Seeder { @@ -11,6 +11,7 @@ class AttributeOptionTableSeeder extends Seeder public function run() { DB::table('attribute_options')->delete(); + DB::table('attribute_option_translations')->delete(); DB::table('attribute_options')->insert([ ['id' => '1', 'admin_name' => 'Red', 'sort_order' => '1', 'attribute_id' => '23'], diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php index 595b37411..829ce982f 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php @@ -2,9 +2,9 @@ namespace Webkul\Attribute\Database\Seeders; -use Illuminate\Database\Seeder; -use DB; use Carbon\Carbon; +use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\DB; class AttributeTableSeeder extends Seeder { @@ -12,6 +12,7 @@ class AttributeTableSeeder extends Seeder public function run() { DB::table('attributes')->delete(); + DB::table('attribute_translations')->delete(); $now = Carbon::now(); @@ -59,9 +60,11 @@ class AttributeTableSeeder extends Seeder ['id' => '23','code' => 'color','admin_name' => 'Color','type' => 'select','validation' => NULL,'position' => '23','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '1','is_user_defined' => '1','is_visible_on_front' => '0', 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], ['id' => '24','code' => 'size','admin_name' => 'Size','type' => 'select','validation' => NULL,'position' => '24','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '1','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], + 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], ['id' => '25','code' => 'brand','admin_name' => 'Brand','type' => 'select','validation' => NULL,'position' => '25','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '1', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now] + 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], + ['id' => '26','code' => 'guest_checkout','admin_name' => 'Guest Checkout','type' => 'boolean','validation' => NULL,'position' => '8','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', + 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], ]); @@ -90,7 +93,8 @@ class AttributeTableSeeder extends Seeder ['id' => '22','locale' => 'en','name' => 'Weight','attribute_id' => '22'], ['id' => '23','locale' => 'en','name' => 'Color','attribute_id' => '23'], ['id' => '24','locale' => 'en','name' => 'Size','attribute_id' => '24'], - ['id' => '25','locale' => 'en','name' => 'Brand','attribute_id' => '25'] + ['id' => '25','locale' => 'en','name' => 'Brand','attribute_id' => '25'], + ['id' => '26','locale' => 'en','name' => 'Allow Guest Checkout','attribute_id' => '26'] ]); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php index b1f9df4a8..148b85486 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php @@ -13,9 +13,9 @@ class DatabaseSeeder extends Seeder */ public function run() { - $this->call(AttributeTableSeeder::class); - $this->call(AttributeOptionTableSeeder::class); $this->call(AttributeFamilyTableSeeder::class); $this->call(AttributeGroupTableSeeder::class); + $this->call(AttributeTableSeeder::class); + $this->call(AttributeOptionTableSeeder::class); } } diff --git a/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php b/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php index c8ab922f7..92430ab43 100644 --- a/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php +++ b/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php @@ -2,15 +2,16 @@ namespace Webkul\CMS\Database\Seeders; -use Illuminate\Database\Seeder; -use DB; use Carbon\Carbon; +use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\DB; class CMSPagesTableSeeder extends Seeder { public function run() { DB::table('cms_pages')->delete(); + DB::table('cms_page_translations')->delete(); DB::table('cms_pages')->insert([ [ diff --git a/packages/Webkul/Checkout/src/Models/Cart.php b/packages/Webkul/Checkout/src/Models/Cart.php index 9088531fa..936215c1c 100755 --- a/packages/Webkul/Checkout/src/Models/Cart.php +++ b/packages/Webkul/Checkout/src/Models/Cart.php @@ -116,11 +116,11 @@ class Cart extends Model implements CartContract } /** - * Checks if cart have downloadable items + * Checks if cart has downloadable items * * @return boolean */ - public function haveDownloadableItems() + public function hasDownloadableItems() { foreach ($this->items as $item) { if ($item->type == 'downloadable') @@ -129,4 +129,20 @@ class Cart extends Model implements CartContract return false; } + + /** + * Checks if cart has items that allow guest checkout + * + * @return boolean + */ + public function hasGuestCheckoutItems() + { + foreach ($this->items as $item) { + if ($item->product->getAttribute('guest_checkout') === 0) { + return false; + } + } + + return true; + } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php b/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php new file mode 100644 index 000000000..fc8e7ec13 --- /dev/null +++ b/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php @@ -0,0 +1,27 @@ +delete(); + + $now = Carbon::now(); + + DB::table('core_config')->insert([ + 'id' => 1, + 'code' => 'catalog.products.guest-checkout.allow-guest-checkout', + 'value' => '1', + 'channel_code' => null, + 'locale_code' => null, + 'created_at' => $now, + 'updated_at' => $now + ]); + } +} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php b/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php index 919a033ef..6d5013d4f 100755 --- a/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php +++ b/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php @@ -18,5 +18,6 @@ class DatabaseSeeder extends Seeder $this->call(CountriesTableSeeder::class); $this->call(StatesTableSeeder::class); $this->call(ChannelTableSeeder::class); + $this->call(ConfigTableSeeder::class); } } diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php new file mode 100644 index 000000000..99a4f1a1e --- /dev/null +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -0,0 +1,115 @@ + 'integer_value', + 'sku' => 'text_value', + 'name' => 'text_value', + 'url_key' => 'text_value', + 'tax_category_id' => 'integer_value', + 'new' => 'boolean_value', + 'featured' => 'boolean_value', + 'visible_individually' => 'boolean_value', + 'status' => 'boolean_value', + 'short_description' => 'text_value', + 'description' => 'text_value', + 'price' => 'float_value', + 'cost' => 'float_value', + 'special_price' => 'float_value', + 'special_price_from' => 'date_value', + 'special_price_to' => 'date_value', + 'meta_title' => 'text_value', + 'meta_keywords' => 'text_value', + 'meta_description' => 'text_value', + 'width' => 'integer_value', + 'height' => 'integer_value', + 'depth' => 'integer_value', + 'weight' => 'integer_value', + 'color' => 'integer_value', + 'size' => 'integer_value', + 'brand' => 'text_value', + 'guest_checkout' => 'boolean_value', + ]; + if (!array_key_exists($attribute, $attributes)) { + return null; + } + return $attributes[$attribute]; + } + /** + * @param array $attributeValueStates + * + * @return \Webkul\Product\Models\Product + * @part ORM + */ + public function haveProduct( + array $configs = [], + array $productStates = [] + ): Product { + $I = $this; + /** @var Product $product */ + $product = factory(Product::class)->states($productStates)->create($configs['productAttributes'] ?? []);; + $I->createAttributeValues($product->id,$configs['attributeValues'] ?? []); + $I->have(ProductInventory::class, array_merge($configs['productInventory'] ?? [], [ + 'product_id' => $product->id, + 'inventory_source_id' => 1, + ])); + Event::fire('catalog.product.create.after', $product); + return $product; + } + private function createAttributeValues($id, array $attributeValues = []) + { + $I = $this; + $productAttributeValues = [ + 'sku', + 'url_key', + 'tax_category_id', + 'price', + 'cost', + 'name', + 'new', + 'visible_individually', + 'featured', + 'status', + 'guest_checkout', + 'short_description', + 'description', + 'meta_title', + 'meta_keywords', + 'meta_description', + 'weight', + ]; + foreach ($productAttributeValues as $attribute) { + $data = ['product_id' => $id]; + if (array_key_exists($attribute, $attributeValues)) { + $fieldName = self::getAttributeFieldName($attribute); + if (! array_key_exists($fieldName, $data)) { + $data[$fieldName] = $attributeValues[$attribute]; + } else { + $data = [$fieldName => $attributeValues[$attribute]]; + } + } + $I->have(ProductAttributeValue::class, $data, $attribute); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php b/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php new file mode 100644 index 000000000..53234a1a5 --- /dev/null +++ b/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php @@ -0,0 +1,27 @@ +define(InventorySource::class, function (Faker $faker) { + $now = date("Y-m-d H:i:s"); + $code = $faker->unique()->word; + return [ + 'code' => $faker->unique()->word, + 'name' => $code, + 'description' => $faker->sentence, + 'contact_name' => $faker->name, + 'contact_email' => $faker->safeEmail, + 'contact_number' => $faker->phoneNumber, + 'country' => $faker->countryCode, + 'state' => $faker->state, + 'city' => $faker->city, + 'street' => $faker->streetAddress, + 'postcode' => $faker->postcode, + 'priority' => 0, + 'status' => 1, + 'created_at' => $now, + 'updated_at' => $now, + ]; +}); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php new file mode 100644 index 000000000..4da6ddaf0 --- /dev/null +++ b/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php @@ -0,0 +1,261 @@ +defineAs(ProductAttributeValue::class, 'sku', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'text_value' => $faker->uuid, + 'attribute_id' => 1, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'name', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'locale' => 'en', //$faker->languageCode, + 'channel' => 'default', + 'text_value' => $faker->words(2, true), + 'attribute_id' => 2, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'url_key', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'text_value' => $faker->unique()->slug, + 'attribute_id' => 3, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'tax_category_id', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'channel' => 'default', + 'integer_value' => null, // ToDo + 'attribute_id' => 4, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'new', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'boolean_value' => 1, + 'attribute_id' => 5, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'featured', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'boolean_value' => 1, + 'attribute_id' => 6, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'visible_individually', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'boolean_value' => 1, + 'attribute_id' => 7, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'status', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'boolean_value' => 1, + 'attribute_id' => 8, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'short_description', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'locale' => 'en', //$faker->languageCode, + 'channel' => 'default', + 'text_value' => $faker->sentence, + 'attribute_id' => 9, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'description', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'locale' => 'en', //$faker->languageCode, + 'channel' => 'default', + 'text_value' => $faker->sentences(3, true), + 'attribute_id' => 10, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'price', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'float_value' => $faker->randomFloat(4, 0, 1000), + 'attribute_id' => 11, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'cost', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'channel' => 'default', + 'float_value' => $faker->randomFloat(4, 0, 10), + 'attribute_id' => 12, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'special_price', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'float_value' => $faker->randomFloat(4, 0, 100), + 'attribute_id' => 13, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'special_price_from', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'channel' => 'default', + 'date_value' => $faker->dateTimeBetween('-5 days', 'now', 'Europe/Berlin'), + 'attribute_id' => 14, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'special_price_to', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'channel' => 'default', + 'date_value' => $faker->dateTimeBetween('now', '+ 5 days', 'Europe/Berlin'), + 'attribute_id' => 15, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'meta_title', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'locale' => 'en', //$faker->languageCode, + 'channel' => 'default', + 'text_value' => $faker->words(2, true), + 'attribute_id' => 16, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'meta_keywords', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'locale' => 'en', //$faker->languageCode, + 'channel' => 'default', + 'text_value' => $faker->words(5, true), + 'attribute_id' => 17, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'meta_description', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'locale' => 'en', //$faker->languageCode, + 'channel' => 'default', + 'text_value' => $faker->sentence, + 'attribute_id' => 18, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'width', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'integer_value' => $faker->numberBetween(1, 50), + 'attribute_id' => 19, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'height', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'integer_value' => $faker->numberBetween(1, 50), + 'attribute_id' => 20, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'depth', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'integer_value' => $faker->numberBetween(1, 50), + 'attribute_id' => 21, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'weight', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'integer_value' => $faker->numberBetween(1, 50), + 'attribute_id' => 22, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'color', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'integer_value' => $faker->numberBetween(1, 5), + 'attribute_id' => 23, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'size', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'integer_value' => $faker->numberBetween(1, 5), + 'attribute_id' => 24, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'brand', function (Faker $faker) { + return [ + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'attribute_id' => 25, + 'integer_value' => function () { + return factory(AttributeOption::class)->create()->id; + }, + ]; +}); +$factory->defineAs(ProductAttributeValue::class, 'guest_checkout', function ( Faker $faker) { + return [ + 'product_id' => function() { + return factory(Product::class)->create()->id; + }, + 'boolean_value' => 1, + 'attribute_id' => 26, + ]; +}); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductFactory.php new file mode 100644 index 000000000..0caf3ded5 --- /dev/null +++ b/packages/Webkul/Product/src/Database/Factories/ProductFactory.php @@ -0,0 +1,23 @@ +define(Product::class, function (Faker $faker) { + $now = date("Y-m-d H:i:s"); + return [ + 'sku' => $faker->uuid, + 'created_at' => $now, + 'updated_at' => $now, + 'attribute_family_id' => 1, + ]; +}); + +$factory->state(Product::class, 'simple', [ + 'type' => 'simple', +]); +$factory->state(Product::class, 'downloadable_with_stock', [ + 'type' => 'downloadable', +]); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php new file mode 100644 index 000000000..fc3b9d122 --- /dev/null +++ b/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php @@ -0,0 +1,20 @@ +define(ProductInventory::class, function (Faker $faker) { + return [ + 'qty' => $faker->numberBetween(1, 20), + 'product_id' => function () { + return factory(Product::class)->create()->id; + }, + 'inventory_source_id' => function () { + return factory(InventorySource::class)->create()->id; + }, + ]; +}); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Providers/ProductServiceProvider.php b/packages/Webkul/Product/src/Providers/ProductServiceProvider.php index 902f5261b..e95c7563f 100755 --- a/packages/Webkul/Product/src/Providers/ProductServiceProvider.php +++ b/packages/Webkul/Product/src/Providers/ProductServiceProvider.php @@ -2,6 +2,7 @@ namespace Webkul\Product\Providers; +use Illuminate\Database\Eloquent\Factory as EloquentFactory; use Illuminate\Support\ServiceProvider; use Webkul\Product\Models\ProductProxy; use Webkul\Product\Observers\ProductObserver; @@ -32,14 +33,21 @@ class ProductServiceProvider extends ServiceProvider * * @return void */ - public function register() + public function register(): void { $this->registerConfig(); $this->registerCommands(); + + $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); } - public function registerConfig() { + /** + * Register Configuration + * + * @return void + */ + public function registerConfig(): void { $this->mergeConfigFrom( dirname(__DIR__) . '/Config/product_types.php', 'product_types' ); @@ -47,10 +55,24 @@ class ProductServiceProvider extends ServiceProvider /** * Register the console commands of this package + * + * @return void */ - protected function registerCommands() + protected function registerCommands(): void { - if ($this->app->runningInConsole()) + if ($this->app->runningInConsole()) { $this->commands([PriceUpdate::class,]); + } + } + + /** + * Register factories. + * + * @param string $path + * @return void + */ + protected function registerEloquentFactoriesFrom($path): void + { + $this->app->make(EloquentFactory::class)->load($path); } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Type/Downloadable.php b/packages/Webkul/Product/src/Type/Downloadable.php index aaf97acdf..fa7cd8c9b 100644 --- a/packages/Webkul/Product/src/Type/Downloadable.php +++ b/packages/Webkul/Product/src/Type/Downloadable.php @@ -22,14 +22,14 @@ class Downloadable extends AbstractType { /** * ProductDownloadableLinkRepository instance - * + * * @var ProductDownloadableLinkRepository */ protected $productDownloadableLinkRepository; /** * ProductDownloadableSampleRepository instance - * + * * @var ProductDownloadableSampleRepository */ protected $productDownloadableSampleRepository; @@ -39,11 +39,11 @@ class Downloadable extends AbstractType * * @var array */ - protected $skipAttributes = ['width', 'height', 'depth', 'weight']; + protected $skipAttributes = ['width', 'height', 'depth', 'weight', 'guest_checkout']; /** * These blade files will be included in product edit page - * + * * @var array */ protected $additionalViews = [ @@ -111,7 +111,7 @@ class Downloadable extends AbstractType if (request()->route()->getName() != 'admin.catalog.products.massupdate') { $this->productDownloadableLinkRepository->saveLinks($data, $product); - + $this->productDownloadableSampleRepository->saveSamples($data, $product); } @@ -127,11 +127,11 @@ class Downloadable extends AbstractType { if (! $this->product->status) return false; - + if ($this->product->downloadable_links()->count()) return true; - return false; + return false; } /** @@ -177,7 +177,7 @@ class Downloadable extends AbstractType return $products; } - + /** * * @param array $options1 diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index 12dad01aa..06fa3dacc 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -64,13 +64,22 @@ class OnepageController extends Controller */ public function index() { + if (! auth()->guard('customer')->check() && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { + return redirect()->route('customer.session.index'); + } + if (Cart::hasError()) return redirect()->route('shop.checkout.cart.index'); $cart = Cart::getCart(); - if (! auth()->guard('customer')->check() && $cart->haveDownloadableItems()) + if (! auth()->guard('customer')->check() && $cart->hasDownloadableItems()) { return redirect()->route('customer.session.index'); + } + + if (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems()) { + return redirect()->route('customer.session.index'); + } Cart::collectTotals(); diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 95c00ec21..9adb03862 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -23,4 +23,20 @@ class AcceptanceTester extends \Codeception\Actor /** * Define custom actions here */ + + /** + * Logging in as an Admin + */ + public function loginAsAdmin() + { + $I = $this; + $I->amOnPage('/admin'); + $I->see('Sign In'); + $I->fillField('email', 'admin@example.com'); + $I->fillField('password', 'admin123'); + $I->dontSee('The "Email" field is required.'); + $I->dontSee('The "Password" field is required.'); + $I->click('Sign In'); + $I->see('Dashboard', '//h1'); + } } diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index ea07902b1..38b53fd7d 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -2,6 +2,7 @@ use Illuminate\Routing\RouteCollection; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Route; use Webkul\User\Models\Admin; @@ -58,4 +59,26 @@ class FunctionalTester extends \Codeception\Actor $I->assertContains('admin', $middlewares, 'check that admin middleware is applied'); } + /** + * Set specific Webkul/Core configuration keys to a given value + * + * // TODO: change method as soon as there is a method to set core config data + * + * @param $data array containing 'code => value' pairs + * @return void + */ + public function setConfigData($data): void { + foreach ($data as $key => $value) { + if (DB::table('core_config')->where('code', '=', $key)->exists()) { + DB::table('core_config')->where('code', '=', $key)->update(['value' => $value]); + } else { + DB::table('core_config')->insert([ + 'code' => $key, + 'value' => $value, + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s') + ]); + } + } + } } diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml index 267af5b80..ba234fcea 100644 --- a/tests/acceptance.suite.yml +++ b/tests/acceptance.suite.yml @@ -7,7 +7,23 @@ actor: AcceptanceTester modules: enabled: - - PhpBrowser: - url: http://localhost - - \Helper\Acceptance - step_decorators: ~ \ No newline at end of file + - \Helper\Acceptance + - Asserts + - WebDriver: + url: http://nginx/ + host: selenium-chrome + browser: chrome + window_size: 1920x1080 + restart: true + wait: 20 + pageload_timeout: 10 + connection_timeout: 60 + request_timeout: 60 + log_js_errors: true + - Laravel5: + part: ORM + cleanup: false + environment_file: .env + database_seeder_class: DatabaseSeeder + url: http://nginx +step_decorators: ~ \ No newline at end of file diff --git a/tests/acceptance/GuestCheckoutCest.php b/tests/acceptance/GuestCheckoutCest.php new file mode 100644 index 000000000..f862a34bf --- /dev/null +++ b/tests/acceptance/GuestCheckoutCest.php @@ -0,0 +1,59 @@ +faker = Factory::create(); + } + + function testToConfigureGlobalGuestCheckout(AcceptanceTester $I) + { + $I->loginAsAdmin(); + + $I->amGoingTo('turn ON the global guest checkout configuration'); + $I->amOnPage('/admin/configuration/catalog/products'); + $I->see(__('admin::app.admin.system.allow-guest-checkout')); + $I->selectOption('catalog[products][guest-checkout][allow-guest-checkout]', 1); + $I->click(__('admin::app.configuration.save-btn-title')); + $I->seeRecord('core_config', ['code' => 'catalog.products.guest-checkout.allow-guest-checkout', 'value' => 1]); + + $I->amGoingTo('assert that the product guest checkout configuration is shown'); + $I->amOnPage('admin/catalog/products'); + $I->click(__('admin::app.catalog.products.add-product-btn-title')); + $I->selectOption('attribute_family_id', 1); + $I->fillField('sku', $this->faker->uuid); + $I->dontSeeInSource('The "SKU" field is required.'); + $I->click(__('admin::app.catalog.products.save-btn-title')); + $I->seeInCurrentUrl('admin/catalog/products/edit'); + $I->scrollTo('#new'); + $I->see('Guest Checkout'); + $I->seeInSource('amGoingTo('turn OFF the global guest checkout configuration'); + $I->amOnPage('/admin/configuration/catalog/products'); + $I->see(__('admin::app.admin.system.allow-guest-checkout')); + $I->selectOption('catalog[products][guest-checkout][allow-guest-checkout]', 0); + $I->click(__('admin::app.configuration.save-btn-title')); + $I->seeRecord('core_config', ['code' => 'catalog.products.guest-checkout.allow-guest-checkout', 'value' => 0]); + + $I->amGoingTo('assert that the product guest checkout configuration is not shown'); + $I->amOnPage('admin/catalog/products'); + $I->click(__('admin::app.catalog.products.add-product-btn-title')); + $I->selectOption('attribute_family_id', 1); + $I->fillField('sku', $this->faker->uuid); + $I->dontSeeInSource('The "SKU" field is required.'); + $I->click(__('admin::app.catalog.products.save-btn-title')); + $I->seeInCurrentUrl('admin/catalog/products/edit'); + $I->scrollTo('#new'); + $I->dontSee('Guest Checkout'); + $I->dontSeeInSource('selectOption('select#attribute_family_id', $attributeFamily->id); - $sku = $this->faker->randomNumber(3); + $sku = $this->faker->uuid; $I->fillField('sku', $sku); $I->click(__('admin::app.catalog.products.save-btn-title')); diff --git a/tests/functional/Shop/GuestCheckoutCest.php b/tests/functional/Shop/GuestCheckoutCest.php new file mode 100644 index 000000000..d6a66f732 --- /dev/null +++ b/tests/functional/Shop/GuestCheckoutCest.php @@ -0,0 +1,90 @@ +faker = Factory::create(); + + $pConfigDefault = [ + 'productInventory' => ['qty' => $this->faker->randomNumber(2)], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'guest_checkout' => 0 + ], + ]; + $pConfigGuestCheckout = [ + 'productInventory' => ['qty' => $this->faker->randomNumber(2)], + 'attributeValues' => [ + 'status' => true, + 'new' => 1, + 'guest_checkout' => 1 + ], + ]; + + $this->productNoGuestCheckout = $I->haveProduct($pConfigDefault, ['simple']); + $this->productNoGuestCheckout->refresh(); + + $this->productGuestCheckout = $I->haveProduct($pConfigGuestCheckout, ['simple']); + $this->productGuestCheckout->refresh(); + } + + public function testGuestCheckout(FunctionalTester $I) { + $I->amGoingTo('try to add products to cart with guest checkout turned on or off'); + + $scenarios = [ + [ + 'name' => 'false / false', + 'globalConfig' => 0, + 'product' => $this->productNoGuestCheckout, + 'expectedRoute' => 'customer.session.index' + ], + [ + 'name' => 'false / true', + 'globalConfig' => 0, + 'product' => $this->productGuestCheckout, + 'expectedRoute' => 'customer.session.index' + ], + [ + 'name' => 'true / false', + 'globalConfig' => 1, + 'product' => $this->productNoGuestCheckout, + 'expectedRoute' => 'customer.session.index' + ], + [ + 'name' => 'true / true', + 'globalConfig' => 1, + 'product' => $this->productGuestCheckout, + 'expectedRoute' => 'shop.checkout.onepage.index' + ], + ]; + + foreach ($scenarios as $scenario) { + $I->wantTo('test conjunction "' . $scenario['name'] . '" with globalConfig = ' . $scenario['globalConfig'] . ' && product config = ' . $scenario['product']->getAttribute('guest_checkout')); + $I->setConfigData(['catalog.products.guest-checkout.allow-guest-checkout' => $scenario['globalConfig']]); + $I->assertEquals($scenario['globalConfig'], core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')); + $I->amOnRoute('shop.home.index'); + $I->see($scenario['product']->name, '//div[@class="product-information"]/div[@class="product-name"]'); + $I->click(__('shop::app.products.add-to-cart'), + '//form[input[@name="product_id"][@value="' . $scenario['product']->id . '"]]/button'); + $I->seeInSource(__('shop::app.checkout.cart.item.success')); + $I->amOnRoute('shop.checkout.cart.index'); + $I->see('Shopping Cart', '//div[@class="title"]'); + $I->makeHtmlSnapshot('guestCheckout_'.$scenario['globalConfig'].'_'.$scenario['product']->getAttribute('guest_checkout')); + $I->see($scenario['product']->name, '//div[@class="item-title"]'); + $I->click( __('shop::app.checkout.cart.proceed-to-checkout'), '//a[@href="' . route('shop.checkout.onepage.index') . '"]'); + $I->seeCurrentRouteIs($scenario['expectedRoute']); + $cart = Cart::getCart(); + $I->assertTrue(Cart::removeItem($cart->items[0]->id)); + } + } +} \ No newline at end of file From cddba75d9e8cad1b30dfd2ea0dd81d6239d6e3aa Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 19:05:56 +0530 Subject: [PATCH 03/30] Added .env.ci file --- .env.ci | 39 +++++++++++++++++++++++++++++++++++++++ .env.testing | 32 +++++++++++++++----------------- 2 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 .env.ci diff --git a/.env.ci b/.env.ci new file mode 100644 index 000000000..5893cf60c --- /dev/null +++ b/.env.ci @@ -0,0 +1,39 @@ +APP_NAME=Laravel +APP_ENV=local +APP_VERSION=0.1.5 +APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE= +APP_DEBUG=true +APP_URL=http://192.168.15.195/laravel/bagisto/public + +LOG_CHANNEL=stack + +DB_CONNECTION=sqlite +DB_DATABASE=:memory: + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=120 +QUEUE_DRIVER=sync + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_DRIVER=smtp +MAIL_HOST=smtp.sendgrid.net +MAIL_PORT=587 +MAIL_USERNAME=helpdeskWebkul +MAIL_PASSWORD=SiM8$GjQCaI)!pTSF^ +MAIL_ENCRYPTION=tls + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +SHOP_MAIL_FROM=jitendra@webkul.com +ADMIN_MAIL_TO=jitendra@webkul.com \ No newline at end of file diff --git a/.env.testing b/.env.testing index 6b1104008..38b5b4884 100644 --- a/.env.testing +++ b/.env.testing @@ -1,23 +1,23 @@ -APP_NAME=Bagisto +APP_NAME=Laravel APP_ENV=local -APP_VERSION=0.1.8 -APP_KEY=base64:NFtGjjFAqET6RlX3PVC/gFpzHb4jK1OxDc3cuU5Asz4= +APP_VERSION=0.1.5 +APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE= APP_DEBUG=true -APP_URL=http://localhost +APP_URL=http://192.168.15.195/laravel/bagisto/public LOG_CHANNEL=stack DB_CONNECTION=mysql -DB_HOST=mysql +DB_HOST=localhost DB_PORT=3306 -DB_DATABASE=bagisto_test +DB_DATABASE=bagisto_testing DB_USERNAME=root -DB_PASSWORD=root +DB_PASSWORD=webkul BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file -SESSION_LIFETIME=20 +SESSION_LIFETIME=120 QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 @@ -25,17 +25,12 @@ REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER=smtp -MAIL_HOST=smtp.mailtrap.io -MAIL_PORT=2525 -MAIL_USERNAME= -MAIL_PASSWORD= +MAIL_HOST=smtp.sendgrid.net +MAIL_PORT=587 +MAIL_USERNAME=helpdeskWebkul +MAIL_PASSWORD=SiM8$GjQCaI)!pTSF^ MAIL_ENCRYPTION=tls -SHOP_MAIL_FROM= -ADMIN_MAIL_TO= - -fixer_api_key= - PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= @@ -43,3 +38,6 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +SHOP_MAIL_FROM=jitendra@webkul.com +ADMIN_MAIL_TO=jitendra@webkul.com \ No newline at end of file From 48ddb65b15b2d9732ddaa120a82fbd388c7adee4 Mon Sep 17 00:00:00 2001 From: Jitendra Singh <39991107+jitendra-webkul@users.noreply.github.com> Date: Tue, 21 Jan 2020 19:07:17 +0530 Subject: [PATCH 04/30] Create ci.yml --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..b16aebf16 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: Bagisto + +on: [push] + +jobs: + laravel-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.ci', '.env');" + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + - name: Generate key + run: php artisan key:generate + - name: Create Database + run: | + mkdir -p database + touch database/database.sqlite + - name: Execute tests (Unit, Feature and Trigger tests) via Codeception + env: + DB_CONNECTION: sqlite + DB_DATABASE: database/database.sqlite + run: | + set -e + @php artisan migrate:fresh --env=testing + vendor/bin/codecept run unit + vendor/bin/codecept run functional + vendor/bin/codecept run trigger From 6ce0ff0f412964b4629f210679d0c4b72d34f9c2 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 19:18:16 +0530 Subject: [PATCH 05/30] composer.lock file updated --- composer.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index b047e7387..7b04d5410 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "06686b2b0cd023b308427381d8ee9184", + "content-hash": "cc056714a51a7ae1a027577b93e07ef1", "packages": [ { "name": "astrotomic/laravel-translatable", @@ -8134,7 +8134,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.1.3", + "php": "^7.2.0", "ext-curl": "*", "ext-intl": "*", "ext-mbstring": "*", From a04ec5a12bd5d48e5cf0ea50455a79dc510647e7 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 19:22:29 +0530 Subject: [PATCH 06/30] Updated ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b16aebf16..633aa90b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + run: composer install - name: Generate key run: php artisan key:generate - name: Create Database From bc70656ec8c06bad1adcc5b49701903e3fef67d1 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 19:58:11 +0530 Subject: [PATCH 07/30] Added php extensions --- .github/workflows/ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 633aa90b0..9c2da1795 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + - name: Setup PHP + uses: shivammathur/setup-php@master + with: + php-version: 7.2.0 + extension-csv: curl, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies @@ -23,7 +28,7 @@ jobs: DB_DATABASE: database/database.sqlite run: | set -e - @php artisan migrate:fresh --env=testing + @php artisan migrate:fresh --env=ci vendor/bin/codecept run unit vendor/bin/codecept run functional - vendor/bin/codecept run trigger + vendor/bin/codecept run trigger \ No newline at end of file From ff41e0e417582f732798f5890aa56be2e18c1d97 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:01:45 +0530 Subject: [PATCH 08/30] Updated ci.yml --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c2da1795..c6d7eb71c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,10 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup PHP - uses: shivammathur/setup-php@master - with: - php-version: 7.2.0 - extension-csv: curl, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer + uses: shivammathur/setup-php@v1 + with: + php-version: '7.4' + extensions: curl, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From a5878915322ba241e9737b4200e9accd4d43b2b7 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:03:36 +0530 Subject: [PATCH 09/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6d7eb71c..47a486fac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,9 +8,9 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup PHP - uses: shivammathur/setup-php@v1 - with: - php-version: '7.4' + uses: shivammathur/setup-php@v1 + with: + php-version: 7.4 extensions: curl, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" From 7258b8dc88befa4d3d934bfadc2c30a1071359c8 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:05:51 +0530 Subject: [PATCH 10/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47a486fac..28fb3d90e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: uses: shivammathur/setup-php@v1 with: php-version: 7.4 - extensions: curl, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer + extensions: intl, mbstring - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From b2e6e8204e6070cad03b2606203ebae673d5dc9d Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:16:59 +0530 Subject: [PATCH 11/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28fb3d90e..3d08190d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v1 with: - php-version: 7.4 - extensions: intl, mbstring + php-version: '7.4' + extensions: intl - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From 0801ab86ea37a6e58664ddfe5709446aa74261cd Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:18:22 +0530 Subject: [PATCH 12/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d08190d4..6aa044f3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: uses: shivammathur/setup-php@v1 with: php-version: '7.4' - extensions: intl + extensions: 'intl' - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From 8a63aa25524adcaf4a85a0c1700f8dfd5888e6a0 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:20:27 +0530 Subject: [PATCH 13/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6aa044f3d..b6ae89915 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,6 @@ jobs: uses: shivammathur/setup-php@v1 with: php-version: '7.4' - extensions: 'intl' - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From c494a3946bd87ae7ac463d8fd9d0d8a48f347cdc Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:22:16 +0530 Subject: [PATCH 14/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6ae89915..422d3eeff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: Setup PHP - uses: shivammathur/setup-php@v1 - with: - php-version: '7.4' - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From 8ed91faa7a1ceed6bd020afc9bbd9441ad208547 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:25:16 +0530 Subject: [PATCH 15/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 422d3eeff..80809325f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + - name: Setup PHP + - uses: shivammathur/setup-php@v1 + with: + extensions: intl + - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From 9d7acc0f11bb4ce1dce24660aab5a0b3919a722c Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:26:57 +0530 Subject: [PATCH 16/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80809325f..788775651 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + - name: Setup PHP - uses: shivammathur/setup-php@v1 with: extensions: intl - + - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From d12ecf74e5bde6b1a1c7a09726aea79e11796251 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:28:47 +0530 Subject: [PATCH 17/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 788775651..896ef9262 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - + - name: Setup PHP - uses: shivammathur/setup-php@v1 with: From da56b54cc7ab42f2bddbd0486f91a51ad66282ee Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:31:22 +0530 Subject: [PATCH 18/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 896ef9262..26a027f3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,10 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Setup PHP - - uses: shivammathur/setup-php@v1 - with: - extensions: intl + - name: Setup PHP + - uses: shivammathur/setup-php@v1 + with: + extensions: intl - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" From b05e27a8bac284ffda642f4945f2b02fc2482e30 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:32:51 +0530 Subject: [PATCH 19/30] Fixed syntax in ci.yml --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26a027f3e..043d7f95b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ jobs: - uses: shivammathur/setup-php@v1 with: extensions: intl - - name: Copy .env run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - name: Install Dependencies From 4b3ec1c9eca7323a0c1b3d13a8937ffa7287292f Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Tue, 21 Jan 2020 20:35:45 +0530 Subject: [PATCH 20/30] Removed ci.yml --- .github/workflows/ci.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 043d7f95b..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Bagisto - -on: [push] - -jobs: - laravel-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Setup PHP - - uses: shivammathur/setup-php@v1 - with: - extensions: intl - - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.ci', '.env');" - - name: Install Dependencies - run: composer install - - name: Generate key - run: php artisan key:generate - - name: Create Database - run: | - mkdir -p database - touch database/database.sqlite - - name: Execute tests (Unit, Feature and Trigger tests) via Codeception - env: - DB_CONNECTION: sqlite - DB_DATABASE: database/database.sqlite - run: | - set -e - @php artisan migrate:fresh --env=ci - vendor/bin/codecept run unit - vendor/bin/codecept run functional - vendor/bin/codecept run trigger \ No newline at end of file From a71ccb522b4b712413774b60b6652010142c2933 Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Tue, 21 Jan 2020 20:01:07 +0100 Subject: [PATCH 21/30] add automated test pipeline --- .env.testing | 6 ++-- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.env.testing b/.env.testing index 38b5b4884..e88f73461 100644 --- a/.env.testing +++ b/.env.testing @@ -8,11 +8,11 @@ APP_URL=http://192.168.15.195/laravel/bagisto/public LOG_CHANNEL=stack DB_CONNECTION=mysql -DB_HOST=localhost +DB_HOST=mysql DB_PORT=3306 DB_DATABASE=bagisto_testing -DB_USERNAME=root -DB_PASSWORD=webkul +DB_USERNAME=bagisto +DB_PASSWORD=secret BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..1a0a1b5dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: CI + +on: + pull_request: + push: + branches: + - master + +jobs: + tests: + name: Run tests + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: bagisto_testing + MYSQL_USER: bagisto + MYSQL_PASSWORD: secret + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup php + uses: shivammathur/setup-php@v1 + with: + php-version: '7.3' + extensions: intl, curl, mbstring, openssl, pdo, pdo_mysql, tokenizer + + - name: Set environment + run: | + set -e + sed -i "s|^\(DB_HOST=\s*\).*$|\1127.0.0.1|" .env.testing + sed -i "s|^\(DB_PORT=\s*\).*$|\1${{ job.services.mysql.ports['3306'] }}|" .env.testing + printf "the complete .env.testing ...\n\n" + cat .env.testing + + - name: Composer install + run: | + set -e + composer global require hirak/prestissimo + composer install --no-interaction --ansi --no-progress --no-suggest --optimize-autoloader + + - name: Migrate database + run: set -e && php artisan migrate --env=testing + + - name: Execute unit tests + run: set -e && vendor/bin/codecept run unit + + - name: Execute functional tests + run: set -e && vendor/bin/codecept run functional + + - name: Execute trigger tests + run: set -e && vendor/bin/codecept run trigger From 9cb3600d7f6d3be6e5286ec15cf4ec4ac441876e Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Tue, 21 Jan 2020 20:13:22 +0100 Subject: [PATCH 22/30] change pipeline-trigger to on: push --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a0a1b5dd..46fc3a4aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,6 @@ name: CI -on: - pull_request: - push: - branches: - - master +on: push jobs: tests: From ec51fa9108c2839d2222cebb35b143f192f6ae98 Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Tue, 21 Jan 2020 20:16:30 +0100 Subject: [PATCH 23/30] change pipeline-trigger to on: push and pull_request --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46fc3a4aa..4f74da491 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: push +on: [push, pull_request] jobs: tests: From 4de857db5a48d4192124d9d3ea5ef070e2f6519f Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Wed, 22 Jan 2020 11:46:48 +0530 Subject: [PATCH 24/30] Convert fire to dispatch --- .env.ci | 39 ------------------- ...{Laravel5Helper.php => Laravel6Helper.php} | 4 +- tests/functional.suite.yml | 2 +- 3 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 .env.ci rename packages/Webkul/Core/src/Helpers/{Laravel5Helper.php => Laravel6Helper.php} (97%) diff --git a/.env.ci b/.env.ci deleted file mode 100644 index 5893cf60c..000000000 --- a/.env.ci +++ /dev/null @@ -1,39 +0,0 @@ -APP_NAME=Laravel -APP_ENV=local -APP_VERSION=0.1.5 -APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE= -APP_DEBUG=true -APP_URL=http://192.168.15.195/laravel/bagisto/public - -LOG_CHANNEL=stack - -DB_CONNECTION=sqlite -DB_DATABASE=:memory: - -BROADCAST_DRIVER=log -CACHE_DRIVER=file -SESSION_DRIVER=file -SESSION_LIFETIME=120 -QUEUE_DRIVER=sync - -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -REDIS_PORT=6379 - -MAIL_DRIVER=smtp -MAIL_HOST=smtp.sendgrid.net -MAIL_PORT=587 -MAIL_USERNAME=helpdeskWebkul -MAIL_PASSWORD=SiM8$GjQCaI)!pTSF^ -MAIL_ENCRYPTION=tls - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_APP_CLUSTER=mt1 - -MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" -MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" - -SHOP_MAIL_FROM=jitendra@webkul.com -ADMIN_MAIL_TO=jitendra@webkul.com \ No newline at end of file diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel6Helper.php similarity index 97% rename from packages/Webkul/Core/src/Helpers/Laravel5Helper.php rename to packages/Webkul/Core/src/Helpers/Laravel6Helper.php index 99a4f1a1e..4b6cefc8c 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel6Helper.php @@ -10,7 +10,7 @@ use Webkul\Product\Models\Product; use Webkul\Product\Models\ProductAttributeValue; use Webkul\Product\Models\ProductInventory; -class Laravel5Helper extends Laravel5 +class Laravel6Helper extends Laravel5 { /** * Returns field name of given attribute. @@ -74,7 +74,7 @@ class Laravel5Helper extends Laravel5 'product_id' => $product->id, 'inventory_source_id' => 1, ])); - Event::fire('catalog.product.create.after', $product); + Event::dispatch('catalog.product.create.after', $product); return $product; } private function createAttributeValues($id, array $attributeValues = []) diff --git a/tests/functional.suite.yml b/tests/functional.suite.yml index eb0a8c008..70da1a9fd 100644 --- a/tests/functional.suite.yml +++ b/tests/functional.suite.yml @@ -11,7 +11,7 @@ modules: # add a framework module here - \Helper\Functional - Asserts - - Webkul\Core\Helpers\Laravel5Helper: + - Webkul\Core\Helpers\Laravel6Helper: environment_file: .env.testing packages: packages cleanup: false From e4cfaff2f6e40f9ad04d03effa6e8ce3ec41b96c Mon Sep 17 00:00:00 2001 From: rahulshukla-webkul <42834394+rahulshukla-webkul@users.noreply.github.com> Date: Wed, 22 Jan 2020 11:53:44 +0530 Subject: [PATCH 25/30] Revert "#2107 add automated test pipeline" --- .env.testing | 6 ++--- .github/workflows/ci.yml | 56 ---------------------------------------- 2 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.env.testing b/.env.testing index e88f73461..38b5b4884 100644 --- a/.env.testing +++ b/.env.testing @@ -8,11 +8,11 @@ APP_URL=http://192.168.15.195/laravel/bagisto/public LOG_CHANNEL=stack DB_CONNECTION=mysql -DB_HOST=mysql +DB_HOST=localhost DB_PORT=3306 DB_DATABASE=bagisto_testing -DB_USERNAME=bagisto -DB_PASSWORD=secret +DB_USERNAME=root +DB_PASSWORD=webkul BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4f74da491..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - tests: - name: Run tests - runs-on: ubuntu-latest - - services: - mysql: - image: mysql:5.7 - env: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: bagisto_testing - MYSQL_USER: bagisto - MYSQL_PASSWORD: secret - ports: - - 3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup php - uses: shivammathur/setup-php@v1 - with: - php-version: '7.3' - extensions: intl, curl, mbstring, openssl, pdo, pdo_mysql, tokenizer - - - name: Set environment - run: | - set -e - sed -i "s|^\(DB_HOST=\s*\).*$|\1127.0.0.1|" .env.testing - sed -i "s|^\(DB_PORT=\s*\).*$|\1${{ job.services.mysql.ports['3306'] }}|" .env.testing - printf "the complete .env.testing ...\n\n" - cat .env.testing - - - name: Composer install - run: | - set -e - composer global require hirak/prestissimo - composer install --no-interaction --ansi --no-progress --no-suggest --optimize-autoloader - - - name: Migrate database - run: set -e && php artisan migrate --env=testing - - - name: Execute unit tests - run: set -e && vendor/bin/codecept run unit - - - name: Execute functional tests - run: set -e && vendor/bin/codecept run functional - - - name: Execute trigger tests - run: set -e && vendor/bin/codecept run trigger From 8bd9f0bc9d9ecd4f3dbf4d44847104262b626a6e Mon Sep 17 00:00:00 2001 From: rahulshukla-webkul <42834394+rahulshukla-webkul@users.noreply.github.com> Date: Wed, 22 Jan 2020 11:58:56 +0530 Subject: [PATCH 26/30] Revert "Resolve #1183 guest checkout configuration" --- .gitignore | 2 - package.json | 10 +- packages/Webkul/Admin/src/Config/system.php | 13 +- .../Admin/src/Resources/lang/en/app.php | 3 - .../views/catalog/products/edit.blade.php | 4 - .../views/configuration/index.blade.php | 5 - .../Seeders/AttributeFamilyTableSeeder.php | 6 +- .../Seeders/AttributeGroupTableSeeder.php | 16 +- .../Seeders/AttributeOptionTableSeeder.php | 3 +- .../Database/Seeders/AttributeTableSeeder.php | 14 +- .../src/Database/Seeders/DatabaseSeeder.php | 4 +- .../Database/Seeders/CMSPagesTableSeeder.php | 5 +- packages/Webkul/Checkout/src/Models/Cart.php | 20 +- .../Database/Seeders/ConfigTableSeeder.php | 27 -- .../src/Database/Seeders/DatabaseSeeder.php | 1 - .../Core/src/Helpers/Laravel5Helper.php | 115 -------- .../Factories/InventorySourceFactory.php | 27 -- .../ProductAttributeValueFactory.php | 261 ------------------ .../src/Database/Factories/ProductFactory.php | 23 -- .../Factories/ProductInventoryFactory.php | 20 -- .../src/Providers/ProductServiceProvider.php | 30 +- .../Webkul/Product/src/Type/Downloadable.php | 16 +- .../Http/Controllers/OnepageController.php | 11 +- tests/_support/AcceptanceTester.php | 16 -- tests/_support/FunctionalTester.php | 23 -- tests/acceptance.suite.yml | 24 +- tests/acceptance/GuestCheckoutCest.php | 59 ---- tests/functional.suite.yml | 4 +- tests/functional/Product/ProductCest.php | 2 +- tests/functional/Shop/GuestCheckoutCest.php | 90 ------ 30 files changed, 40 insertions(+), 814 deletions(-) delete mode 100644 packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php delete mode 100644 packages/Webkul/Core/src/Helpers/Laravel5Helper.php delete mode 100644 packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php delete mode 100644 packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php delete mode 100644 packages/Webkul/Product/src/Database/Factories/ProductFactory.php delete mode 100644 packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php delete mode 100644 tests/acceptance/GuestCheckoutCest.php delete mode 100644 tests/functional/Shop/GuestCheckoutCest.php diff --git a/.gitignore b/.gitignore index dcc2b12e3..fd6d5bc53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/docker-compose-collection -/bin /node_modules /public/hot /public/storage diff --git a/package.json b/package.json index 103d618f3..88cbe757f 100755 --- a/package.json +++ b/package.json @@ -13,16 +13,12 @@ "devDependencies": { "axios": "^0.18", "bootstrap": "^4.0.0", + "popper.js": "^1.12", "cross-env": "^5.1", "jquery": "^3.2", - "laravel-mix": "^5.0.1", + "laravel-mix": "^2.0", "lodash": "^4.17.4", - "popper.js": "^1.12", - "resolve-url-loader": "^3.1.0", - "sass": "^1.24.5", - "sass-loader": "^8.0.2", - "vue": "^2.5.7", - "vue-template-compiler": "^2.6.11" + "vue": "^2.5.7" }, "dependencies": { "opencollective-postinstall": "^2.0.1", diff --git a/packages/Webkul/Admin/src/Config/system.php b/packages/Webkul/Admin/src/Config/system.php index 39148ce20..d9a39ee19 100644 --- a/packages/Webkul/Admin/src/Config/system.php +++ b/packages/Webkul/Admin/src/Config/system.php @@ -87,21 +87,10 @@ return [ 'key' => 'catalog.products', 'name' => 'admin::app.admin.system.products', 'sort' => 2 - ], [ - 'key' => 'catalog.products.guest-checkout', - 'name' => 'admin::app.admin.system.guest-checkout', - 'sort' => 1, - 'fields' => [ - [ - 'name' => 'allow-guest-checkout', - 'title' => 'admin::app.admin.system.allow-guest-checkout', - 'type' => 'boolean' - ] - ] ], [ 'key' => 'catalog.products.review', 'name' => 'admin::app.admin.system.review', - 'sort' => 2, + 'sort' => 1, 'fields' => [ [ 'name' => 'guest_review', diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index adae4ecc7..71aa08dac 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -1202,9 +1202,6 @@ return [ 'system' => [ 'catalog' => 'Catalog', 'products' => 'Products', - 'guest-checkout' => 'Guest Checkout', - 'allow-guest-checkout' => 'Allow Guest Checkout', - 'allow-guest-checkout-hint' => 'Hint: If turned on, this option can be configured for each product specifically.', 'review' => 'Review', 'allow-guest-review' => 'Allow Guest Review', 'inventory' => 'Inventory', diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php index 6adba4afc..e76ff2035 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php @@ -77,10 +77,6 @@ @foreach ($customAttributes as $attribute) code == 'guest_checkout' && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { - continue; - } - $validations = []; if ($attribute->is_required) { diff --git a/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php b/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php index 0e7068d94..d31e62144 100755 --- a/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/configuration/index.blade.php @@ -65,11 +65,6 @@ @include ('admin::configuration.field-type', ['field' => $field]) - @php ($hint = $field['title'] . '-hint') - @if ($hint !== __($hint)) - {{ __($hint) }} - @endif - @endforeach diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php index 9926ecd3d..c93bec117 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php @@ -3,20 +3,16 @@ namespace Webkul\Attribute\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; +use DB; class AttributeFamilyTableSeeder extends Seeder { public function run() { - DB::statement('SET FOREIGN_KEY_CHECKS=0;'); - DB::table('attribute_families')->delete(); DB::table('attribute_families')->insert([ ['id' => '1','code' => 'default','name' => 'Default','status' => '0','is_user_defined' => '1'] ]); - - DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php index 394c5ac48..92fa5db6c 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php @@ -3,17 +3,12 @@ namespace Webkul\Attribute\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; +use DB; class AttributeGroupTableSeeder extends Seeder { public function run() { - DB::statement('SET FOREIGN_KEY_CHECKS=0;'); - - DB::table('attribute_groups')->delete(); - DB::table('attribute_group_mappings')->delete(); - DB::table('attribute_groups')->delete(); DB::table('attribute_groups')->insert([ @@ -47,12 +42,9 @@ class AttributeGroupTableSeeder extends Seeder ['attribute_id' => '20','attribute_group_id' => '5','position' => '2'], ['attribute_id' => '21','attribute_group_id' => '5','position' => '3'], ['attribute_id' => '22','attribute_group_id' => '5','position' => '4'], - ['attribute_id' => '23','attribute_group_id' => '1','position' => '10'], - ['attribute_id' => '24','attribute_group_id' => '1','position' => '11'], - ['attribute_id' => '25','attribute_group_id' => '1','position' => '12'], - ['attribute_id' => '26','attribute_group_id' => '1','position' => '9'] + ['attribute_id' => '23','attribute_group_id' => '1','position' => '9'], + ['attribute_id' => '24','attribute_group_id' => '1','position' => '10'], + ['attribute_id' => '25','attribute_group_id' => '1','position' => '11'] ]); - - DB::statement('SET FOREIGN_KEY_CHECKS=0;'); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php index 5bdc0ba9e..992c625c0 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php @@ -3,7 +3,7 @@ namespace Webkul\Attribute\Database\Seeders; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; +use DB; class AttributeOptionTableSeeder extends Seeder { @@ -11,7 +11,6 @@ class AttributeOptionTableSeeder extends Seeder public function run() { DB::table('attribute_options')->delete(); - DB::table('attribute_option_translations')->delete(); DB::table('attribute_options')->insert([ ['id' => '1', 'admin_name' => 'Red', 'sort_order' => '1', 'attribute_id' => '23'], diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php index 829ce982f..595b37411 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php @@ -2,9 +2,9 @@ namespace Webkul\Attribute\Database\Seeders; -use Carbon\Carbon; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; +use DB; +use Carbon\Carbon; class AttributeTableSeeder extends Seeder { @@ -12,7 +12,6 @@ class AttributeTableSeeder extends Seeder public function run() { DB::table('attributes')->delete(); - DB::table('attribute_translations')->delete(); $now = Carbon::now(); @@ -60,11 +59,9 @@ class AttributeTableSeeder extends Seeder ['id' => '23','code' => 'color','admin_name' => 'Color','type' => 'select','validation' => NULL,'position' => '23','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '1','is_user_defined' => '1','is_visible_on_front' => '0', 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], ['id' => '24','code' => 'size','admin_name' => 'Size','type' => 'select','validation' => NULL,'position' => '24','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '1','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], + 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], ['id' => '25','code' => 'brand','admin_name' => 'Brand','type' => 'select','validation' => NULL,'position' => '25','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '1', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], - ['id' => '26','code' => 'guest_checkout','admin_name' => 'Guest Checkout','type' => 'boolean','validation' => NULL,'position' => '8','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now], + 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now] ]); @@ -93,8 +90,7 @@ class AttributeTableSeeder extends Seeder ['id' => '22','locale' => 'en','name' => 'Weight','attribute_id' => '22'], ['id' => '23','locale' => 'en','name' => 'Color','attribute_id' => '23'], ['id' => '24','locale' => 'en','name' => 'Size','attribute_id' => '24'], - ['id' => '25','locale' => 'en','name' => 'Brand','attribute_id' => '25'], - ['id' => '26','locale' => 'en','name' => 'Allow Guest Checkout','attribute_id' => '26'] + ['id' => '25','locale' => 'en','name' => 'Brand','attribute_id' => '25'] ]); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php index 148b85486..b1f9df4a8 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/DatabaseSeeder.php @@ -13,9 +13,9 @@ class DatabaseSeeder extends Seeder */ public function run() { - $this->call(AttributeFamilyTableSeeder::class); - $this->call(AttributeGroupTableSeeder::class); $this->call(AttributeTableSeeder::class); $this->call(AttributeOptionTableSeeder::class); + $this->call(AttributeFamilyTableSeeder::class); + $this->call(AttributeGroupTableSeeder::class); } } diff --git a/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php b/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php index 92430ab43..c8ab922f7 100644 --- a/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php +++ b/packages/Webkul/CMS/src/Database/Seeders/CMSPagesTableSeeder.php @@ -2,16 +2,15 @@ namespace Webkul\CMS\Database\Seeders; -use Carbon\Carbon; use Illuminate\Database\Seeder; -use Illuminate\Support\Facades\DB; +use DB; +use Carbon\Carbon; class CMSPagesTableSeeder extends Seeder { public function run() { DB::table('cms_pages')->delete(); - DB::table('cms_page_translations')->delete(); DB::table('cms_pages')->insert([ [ diff --git a/packages/Webkul/Checkout/src/Models/Cart.php b/packages/Webkul/Checkout/src/Models/Cart.php index 936215c1c..9088531fa 100755 --- a/packages/Webkul/Checkout/src/Models/Cart.php +++ b/packages/Webkul/Checkout/src/Models/Cart.php @@ -116,11 +116,11 @@ class Cart extends Model implements CartContract } /** - * Checks if cart has downloadable items + * Checks if cart have downloadable items * * @return boolean */ - public function hasDownloadableItems() + public function haveDownloadableItems() { foreach ($this->items as $item) { if ($item->type == 'downloadable') @@ -129,20 +129,4 @@ class Cart extends Model implements CartContract return false; } - - /** - * Checks if cart has items that allow guest checkout - * - * @return boolean - */ - public function hasGuestCheckoutItems() - { - foreach ($this->items as $item) { - if ($item->product->getAttribute('guest_checkout') === 0) { - return false; - } - } - - return true; - } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php b/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php deleted file mode 100644 index fc8e7ec13..000000000 --- a/packages/Webkul/Core/src/Database/Seeders/ConfigTableSeeder.php +++ /dev/null @@ -1,27 +0,0 @@ -delete(); - - $now = Carbon::now(); - - DB::table('core_config')->insert([ - 'id' => 1, - 'code' => 'catalog.products.guest-checkout.allow-guest-checkout', - 'value' => '1', - 'channel_code' => null, - 'locale_code' => null, - 'created_at' => $now, - 'updated_at' => $now - ]); - } -} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php b/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php index 6d5013d4f..919a033ef 100755 --- a/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php +++ b/packages/Webkul/Core/src/Database/Seeders/DatabaseSeeder.php @@ -18,6 +18,5 @@ class DatabaseSeeder extends Seeder $this->call(CountriesTableSeeder::class); $this->call(StatesTableSeeder::class); $this->call(ChannelTableSeeder::class); - $this->call(ConfigTableSeeder::class); } } diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php deleted file mode 100644 index 99a4f1a1e..000000000 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ /dev/null @@ -1,115 +0,0 @@ - 'integer_value', - 'sku' => 'text_value', - 'name' => 'text_value', - 'url_key' => 'text_value', - 'tax_category_id' => 'integer_value', - 'new' => 'boolean_value', - 'featured' => 'boolean_value', - 'visible_individually' => 'boolean_value', - 'status' => 'boolean_value', - 'short_description' => 'text_value', - 'description' => 'text_value', - 'price' => 'float_value', - 'cost' => 'float_value', - 'special_price' => 'float_value', - 'special_price_from' => 'date_value', - 'special_price_to' => 'date_value', - 'meta_title' => 'text_value', - 'meta_keywords' => 'text_value', - 'meta_description' => 'text_value', - 'width' => 'integer_value', - 'height' => 'integer_value', - 'depth' => 'integer_value', - 'weight' => 'integer_value', - 'color' => 'integer_value', - 'size' => 'integer_value', - 'brand' => 'text_value', - 'guest_checkout' => 'boolean_value', - ]; - if (!array_key_exists($attribute, $attributes)) { - return null; - } - return $attributes[$attribute]; - } - /** - * @param array $attributeValueStates - * - * @return \Webkul\Product\Models\Product - * @part ORM - */ - public function haveProduct( - array $configs = [], - array $productStates = [] - ): Product { - $I = $this; - /** @var Product $product */ - $product = factory(Product::class)->states($productStates)->create($configs['productAttributes'] ?? []);; - $I->createAttributeValues($product->id,$configs['attributeValues'] ?? []); - $I->have(ProductInventory::class, array_merge($configs['productInventory'] ?? [], [ - 'product_id' => $product->id, - 'inventory_source_id' => 1, - ])); - Event::fire('catalog.product.create.after', $product); - return $product; - } - private function createAttributeValues($id, array $attributeValues = []) - { - $I = $this; - $productAttributeValues = [ - 'sku', - 'url_key', - 'tax_category_id', - 'price', - 'cost', - 'name', - 'new', - 'visible_individually', - 'featured', - 'status', - 'guest_checkout', - 'short_description', - 'description', - 'meta_title', - 'meta_keywords', - 'meta_description', - 'weight', - ]; - foreach ($productAttributeValues as $attribute) { - $data = ['product_id' => $id]; - if (array_key_exists($attribute, $attributeValues)) { - $fieldName = self::getAttributeFieldName($attribute); - if (! array_key_exists($fieldName, $data)) { - $data[$fieldName] = $attributeValues[$attribute]; - } else { - $data = [$fieldName => $attributeValues[$attribute]]; - } - } - $I->have(ProductAttributeValue::class, $data, $attribute); - } - } -} \ No newline at end of file diff --git a/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php b/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php deleted file mode 100644 index 53234a1a5..000000000 --- a/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php +++ /dev/null @@ -1,27 +0,0 @@ -define(InventorySource::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - $code = $faker->unique()->word; - return [ - 'code' => $faker->unique()->word, - 'name' => $code, - 'description' => $faker->sentence, - 'contact_name' => $faker->name, - 'contact_email' => $faker->safeEmail, - 'contact_number' => $faker->phoneNumber, - 'country' => $faker->countryCode, - 'state' => $faker->state, - 'city' => $faker->city, - 'street' => $faker->streetAddress, - 'postcode' => $faker->postcode, - 'priority' => 0, - 'status' => 1, - 'created_at' => $now, - 'updated_at' => $now, - ]; -}); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php deleted file mode 100644 index 4da6ddaf0..000000000 --- a/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php +++ /dev/null @@ -1,261 +0,0 @@ -defineAs(ProductAttributeValue::class, 'sku', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'text_value' => $faker->uuid, - 'attribute_id' => 1, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'name', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->words(2, true), - 'attribute_id' => 2, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'url_key', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'text_value' => $faker->unique()->slug, - 'attribute_id' => 3, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'tax_category_id', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'integer_value' => null, // ToDo - 'attribute_id' => 4, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'new', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 5, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'featured', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 6, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'visible_individually', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 7, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'status', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 8, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'short_description', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->sentence, - 'attribute_id' => 9, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'description', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->sentences(3, true), - 'attribute_id' => 10, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'price', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'float_value' => $faker->randomFloat(4, 0, 1000), - 'attribute_id' => 11, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'cost', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'float_value' => $faker->randomFloat(4, 0, 10), - 'attribute_id' => 12, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'special_price', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'float_value' => $faker->randomFloat(4, 0, 100), - 'attribute_id' => 13, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'special_price_from', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'date_value' => $faker->dateTimeBetween('-5 days', 'now', 'Europe/Berlin'), - 'attribute_id' => 14, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'special_price_to', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'channel' => 'default', - 'date_value' => $faker->dateTimeBetween('now', '+ 5 days', 'Europe/Berlin'), - 'attribute_id' => 15, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'meta_title', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->words(2, true), - 'attribute_id' => 16, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'meta_keywords', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->words(5, true), - 'attribute_id' => 17, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'meta_description', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'locale' => 'en', //$faker->languageCode, - 'channel' => 'default', - 'text_value' => $faker->sentence, - 'attribute_id' => 18, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'width', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 19, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'height', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 20, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'depth', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 21, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'weight', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 50), - 'attribute_id' => 22, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'color', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 5), - 'attribute_id' => 23, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'size', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'integer_value' => $faker->numberBetween(1, 5), - 'attribute_id' => 24, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'brand', function (Faker $faker) { - return [ - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'attribute_id' => 25, - 'integer_value' => function () { - return factory(AttributeOption::class)->create()->id; - }, - ]; -}); -$factory->defineAs(ProductAttributeValue::class, 'guest_checkout', function ( Faker $faker) { - return [ - 'product_id' => function() { - return factory(Product::class)->create()->id; - }, - 'boolean_value' => 1, - 'attribute_id' => 26, - ]; -}); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductFactory.php deleted file mode 100644 index 0caf3ded5..000000000 --- a/packages/Webkul/Product/src/Database/Factories/ProductFactory.php +++ /dev/null @@ -1,23 +0,0 @@ -define(Product::class, function (Faker $faker) { - $now = date("Y-m-d H:i:s"); - return [ - 'sku' => $faker->uuid, - 'created_at' => $now, - 'updated_at' => $now, - 'attribute_family_id' => 1, - ]; -}); - -$factory->state(Product::class, 'simple', [ - 'type' => 'simple', -]); -$factory->state(Product::class, 'downloadable_with_stock', [ - 'type' => 'downloadable', -]); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php deleted file mode 100644 index fc3b9d122..000000000 --- a/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php +++ /dev/null @@ -1,20 +0,0 @@ -define(ProductInventory::class, function (Faker $faker) { - return [ - 'qty' => $faker->numberBetween(1, 20), - 'product_id' => function () { - return factory(Product::class)->create()->id; - }, - 'inventory_source_id' => function () { - return factory(InventorySource::class)->create()->id; - }, - ]; -}); \ No newline at end of file diff --git a/packages/Webkul/Product/src/Providers/ProductServiceProvider.php b/packages/Webkul/Product/src/Providers/ProductServiceProvider.php index e95c7563f..902f5261b 100755 --- a/packages/Webkul/Product/src/Providers/ProductServiceProvider.php +++ b/packages/Webkul/Product/src/Providers/ProductServiceProvider.php @@ -2,7 +2,6 @@ namespace Webkul\Product\Providers; -use Illuminate\Database\Eloquent\Factory as EloquentFactory; use Illuminate\Support\ServiceProvider; use Webkul\Product\Models\ProductProxy; use Webkul\Product\Observers\ProductObserver; @@ -33,21 +32,14 @@ class ProductServiceProvider extends ServiceProvider * * @return void */ - public function register(): void + public function register() { $this->registerConfig(); $this->registerCommands(); - - $this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories'); } - /** - * Register Configuration - * - * @return void - */ - public function registerConfig(): void { + public function registerConfig() { $this->mergeConfigFrom( dirname(__DIR__) . '/Config/product_types.php', 'product_types' ); @@ -55,24 +47,10 @@ class ProductServiceProvider extends ServiceProvider /** * Register the console commands of this package - * - * @return void */ - protected function registerCommands(): void + protected function registerCommands() { - if ($this->app->runningInConsole()) { + if ($this->app->runningInConsole()) $this->commands([PriceUpdate::class,]); - } - } - - /** - * Register factories. - * - * @param string $path - * @return void - */ - protected function registerEloquentFactoriesFrom($path): void - { - $this->app->make(EloquentFactory::class)->load($path); } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Type/Downloadable.php b/packages/Webkul/Product/src/Type/Downloadable.php index fa7cd8c9b..aaf97acdf 100644 --- a/packages/Webkul/Product/src/Type/Downloadable.php +++ b/packages/Webkul/Product/src/Type/Downloadable.php @@ -22,14 +22,14 @@ class Downloadable extends AbstractType { /** * ProductDownloadableLinkRepository instance - * + * * @var ProductDownloadableLinkRepository */ protected $productDownloadableLinkRepository; /** * ProductDownloadableSampleRepository instance - * + * * @var ProductDownloadableSampleRepository */ protected $productDownloadableSampleRepository; @@ -39,11 +39,11 @@ class Downloadable extends AbstractType * * @var array */ - protected $skipAttributes = ['width', 'height', 'depth', 'weight', 'guest_checkout']; + protected $skipAttributes = ['width', 'height', 'depth', 'weight']; /** * These blade files will be included in product edit page - * + * * @var array */ protected $additionalViews = [ @@ -111,7 +111,7 @@ class Downloadable extends AbstractType if (request()->route()->getName() != 'admin.catalog.products.massupdate') { $this->productDownloadableLinkRepository->saveLinks($data, $product); - + $this->productDownloadableSampleRepository->saveSamples($data, $product); } @@ -127,11 +127,11 @@ class Downloadable extends AbstractType { if (! $this->product->status) return false; - + if ($this->product->downloadable_links()->count()) return true; - return false; + return false; } /** @@ -177,7 +177,7 @@ class Downloadable extends AbstractType return $products; } - + /** * * @param array $options1 diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index 06fa3dacc..12dad01aa 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -64,22 +64,13 @@ class OnepageController extends Controller */ public function index() { - if (! auth()->guard('customer')->check() && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { - return redirect()->route('customer.session.index'); - } - if (Cart::hasError()) return redirect()->route('shop.checkout.cart.index'); $cart = Cart::getCart(); - if (! auth()->guard('customer')->check() && $cart->hasDownloadableItems()) { + if (! auth()->guard('customer')->check() && $cart->haveDownloadableItems()) return redirect()->route('customer.session.index'); - } - - if (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems()) { - return redirect()->route('customer.session.index'); - } Cart::collectTotals(); diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 9adb03862..95c00ec21 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -23,20 +23,4 @@ class AcceptanceTester extends \Codeception\Actor /** * Define custom actions here */ - - /** - * Logging in as an Admin - */ - public function loginAsAdmin() - { - $I = $this; - $I->amOnPage('/admin'); - $I->see('Sign In'); - $I->fillField('email', 'admin@example.com'); - $I->fillField('password', 'admin123'); - $I->dontSee('The "Email" field is required.'); - $I->dontSee('The "Password" field is required.'); - $I->click('Sign In'); - $I->see('Dashboard', '//h1'); - } } diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index 38b53fd7d..ea07902b1 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -2,7 +2,6 @@ use Illuminate\Routing\RouteCollection; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Route; use Webkul\User\Models\Admin; @@ -59,26 +58,4 @@ class FunctionalTester extends \Codeception\Actor $I->assertContains('admin', $middlewares, 'check that admin middleware is applied'); } - /** - * Set specific Webkul/Core configuration keys to a given value - * - * // TODO: change method as soon as there is a method to set core config data - * - * @param $data array containing 'code => value' pairs - * @return void - */ - public function setConfigData($data): void { - foreach ($data as $key => $value) { - if (DB::table('core_config')->where('code', '=', $key)->exists()) { - DB::table('core_config')->where('code', '=', $key)->update(['value' => $value]); - } else { - DB::table('core_config')->insert([ - 'code' => $key, - 'value' => $value, - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s') - ]); - } - } - } } diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml index ba234fcea..267af5b80 100644 --- a/tests/acceptance.suite.yml +++ b/tests/acceptance.suite.yml @@ -7,23 +7,7 @@ actor: AcceptanceTester modules: enabled: - - \Helper\Acceptance - - Asserts - - WebDriver: - url: http://nginx/ - host: selenium-chrome - browser: chrome - window_size: 1920x1080 - restart: true - wait: 20 - pageload_timeout: 10 - connection_timeout: 60 - request_timeout: 60 - log_js_errors: true - - Laravel5: - part: ORM - cleanup: false - environment_file: .env - database_seeder_class: DatabaseSeeder - url: http://nginx -step_decorators: ~ \ No newline at end of file + - PhpBrowser: + url: http://localhost + - \Helper\Acceptance + step_decorators: ~ \ No newline at end of file diff --git a/tests/acceptance/GuestCheckoutCest.php b/tests/acceptance/GuestCheckoutCest.php deleted file mode 100644 index f862a34bf..000000000 --- a/tests/acceptance/GuestCheckoutCest.php +++ /dev/null @@ -1,59 +0,0 @@ -faker = Factory::create(); - } - - function testToConfigureGlobalGuestCheckout(AcceptanceTester $I) - { - $I->loginAsAdmin(); - - $I->amGoingTo('turn ON the global guest checkout configuration'); - $I->amOnPage('/admin/configuration/catalog/products'); - $I->see(__('admin::app.admin.system.allow-guest-checkout')); - $I->selectOption('catalog[products][guest-checkout][allow-guest-checkout]', 1); - $I->click(__('admin::app.configuration.save-btn-title')); - $I->seeRecord('core_config', ['code' => 'catalog.products.guest-checkout.allow-guest-checkout', 'value' => 1]); - - $I->amGoingTo('assert that the product guest checkout configuration is shown'); - $I->amOnPage('admin/catalog/products'); - $I->click(__('admin::app.catalog.products.add-product-btn-title')); - $I->selectOption('attribute_family_id', 1); - $I->fillField('sku', $this->faker->uuid); - $I->dontSeeInSource('The "SKU" field is required.'); - $I->click(__('admin::app.catalog.products.save-btn-title')); - $I->seeInCurrentUrl('admin/catalog/products/edit'); - $I->scrollTo('#new'); - $I->see('Guest Checkout'); - $I->seeInSource('amGoingTo('turn OFF the global guest checkout configuration'); - $I->amOnPage('/admin/configuration/catalog/products'); - $I->see(__('admin::app.admin.system.allow-guest-checkout')); - $I->selectOption('catalog[products][guest-checkout][allow-guest-checkout]', 0); - $I->click(__('admin::app.configuration.save-btn-title')); - $I->seeRecord('core_config', ['code' => 'catalog.products.guest-checkout.allow-guest-checkout', 'value' => 0]); - - $I->amGoingTo('assert that the product guest checkout configuration is not shown'); - $I->amOnPage('admin/catalog/products'); - $I->click(__('admin::app.catalog.products.add-product-btn-title')); - $I->selectOption('attribute_family_id', 1); - $I->fillField('sku', $this->faker->uuid); - $I->dontSeeInSource('The "SKU" field is required.'); - $I->click(__('admin::app.catalog.products.save-btn-title')); - $I->seeInCurrentUrl('admin/catalog/products/edit'); - $I->scrollTo('#new'); - $I->dontSee('Guest Checkout'); - $I->dontSeeInSource('selectOption('select#attribute_family_id', $attributeFamily->id); - $sku = $this->faker->uuid; + $sku = $this->faker->randomNumber(3); $I->fillField('sku', $sku); $I->click(__('admin::app.catalog.products.save-btn-title')); diff --git a/tests/functional/Shop/GuestCheckoutCest.php b/tests/functional/Shop/GuestCheckoutCest.php deleted file mode 100644 index d6a66f732..000000000 --- a/tests/functional/Shop/GuestCheckoutCest.php +++ /dev/null @@ -1,90 +0,0 @@ -faker = Factory::create(); - - $pConfigDefault = [ - 'productInventory' => ['qty' => $this->faker->randomNumber(2)], - 'attributeValues' => [ - 'status' => true, - 'new' => 1, - 'guest_checkout' => 0 - ], - ]; - $pConfigGuestCheckout = [ - 'productInventory' => ['qty' => $this->faker->randomNumber(2)], - 'attributeValues' => [ - 'status' => true, - 'new' => 1, - 'guest_checkout' => 1 - ], - ]; - - $this->productNoGuestCheckout = $I->haveProduct($pConfigDefault, ['simple']); - $this->productNoGuestCheckout->refresh(); - - $this->productGuestCheckout = $I->haveProduct($pConfigGuestCheckout, ['simple']); - $this->productGuestCheckout->refresh(); - } - - public function testGuestCheckout(FunctionalTester $I) { - $I->amGoingTo('try to add products to cart with guest checkout turned on or off'); - - $scenarios = [ - [ - 'name' => 'false / false', - 'globalConfig' => 0, - 'product' => $this->productNoGuestCheckout, - 'expectedRoute' => 'customer.session.index' - ], - [ - 'name' => 'false / true', - 'globalConfig' => 0, - 'product' => $this->productGuestCheckout, - 'expectedRoute' => 'customer.session.index' - ], - [ - 'name' => 'true / false', - 'globalConfig' => 1, - 'product' => $this->productNoGuestCheckout, - 'expectedRoute' => 'customer.session.index' - ], - [ - 'name' => 'true / true', - 'globalConfig' => 1, - 'product' => $this->productGuestCheckout, - 'expectedRoute' => 'shop.checkout.onepage.index' - ], - ]; - - foreach ($scenarios as $scenario) { - $I->wantTo('test conjunction "' . $scenario['name'] . '" with globalConfig = ' . $scenario['globalConfig'] . ' && product config = ' . $scenario['product']->getAttribute('guest_checkout')); - $I->setConfigData(['catalog.products.guest-checkout.allow-guest-checkout' => $scenario['globalConfig']]); - $I->assertEquals($scenario['globalConfig'], core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')); - $I->amOnRoute('shop.home.index'); - $I->see($scenario['product']->name, '//div[@class="product-information"]/div[@class="product-name"]'); - $I->click(__('shop::app.products.add-to-cart'), - '//form[input[@name="product_id"][@value="' . $scenario['product']->id . '"]]/button'); - $I->seeInSource(__('shop::app.checkout.cart.item.success')); - $I->amOnRoute('shop.checkout.cart.index'); - $I->see('Shopping Cart', '//div[@class="title"]'); - $I->makeHtmlSnapshot('guestCheckout_'.$scenario['globalConfig'].'_'.$scenario['product']->getAttribute('guest_checkout')); - $I->see($scenario['product']->name, '//div[@class="item-title"]'); - $I->click( __('shop::app.checkout.cart.proceed-to-checkout'), '//a[@href="' . route('shop.checkout.onepage.index') . '"]'); - $I->seeCurrentRouteIs($scenario['expectedRoute']); - $cart = Cart::getCart(); - $I->assertTrue(Cart::removeItem($cart->items[0]->id)); - } - } -} \ No newline at end of file From a2dda0eea0f907845eb27c2c09a8a630ac4f0468 Mon Sep 17 00:00:00 2001 From: Jitendra Singh <39991107+jitendra-webkul@users.noreply.github.com> Date: Wed, 22 Jan 2020 12:10:12 +0530 Subject: [PATCH 27/30] Revert "Revert "#2107 add automated test pipeline"" --- .env.testing | 6 ++--- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.env.testing b/.env.testing index 38b5b4884..e88f73461 100644 --- a/.env.testing +++ b/.env.testing @@ -8,11 +8,11 @@ APP_URL=http://192.168.15.195/laravel/bagisto/public LOG_CHANNEL=stack DB_CONNECTION=mysql -DB_HOST=localhost +DB_HOST=mysql DB_PORT=3306 DB_DATABASE=bagisto_testing -DB_USERNAME=root -DB_PASSWORD=webkul +DB_USERNAME=bagisto +DB_PASSWORD=secret BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..4f74da491 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +on: [push, pull_request] + +jobs: + tests: + name: Run tests + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: bagisto_testing + MYSQL_USER: bagisto + MYSQL_PASSWORD: secret + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup php + uses: shivammathur/setup-php@v1 + with: + php-version: '7.3' + extensions: intl, curl, mbstring, openssl, pdo, pdo_mysql, tokenizer + + - name: Set environment + run: | + set -e + sed -i "s|^\(DB_HOST=\s*\).*$|\1127.0.0.1|" .env.testing + sed -i "s|^\(DB_PORT=\s*\).*$|\1${{ job.services.mysql.ports['3306'] }}|" .env.testing + printf "the complete .env.testing ...\n\n" + cat .env.testing + + - name: Composer install + run: | + set -e + composer global require hirak/prestissimo + composer install --no-interaction --ansi --no-progress --no-suggest --optimize-autoloader + + - name: Migrate database + run: set -e && php artisan migrate --env=testing + + - name: Execute unit tests + run: set -e && vendor/bin/codecept run unit + + - name: Execute functional tests + run: set -e && vendor/bin/codecept run functional + + - name: Execute trigger tests + run: set -e && vendor/bin/codecept run trigger From aa932c7ed2672e436aecd44256da812974b775f4 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Wed, 22 Jan 2020 13:28:34 +0530 Subject: [PATCH 28/30] Fixed issue --- .env.testing | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.env.testing b/.env.testing index e88f73461..0d7ae04d9 100644 --- a/.env.testing +++ b/.env.testing @@ -25,12 +25,13 @@ REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER=smtp -MAIL_HOST=smtp.sendgrid.net -MAIL_PORT=587 -MAIL_USERNAME=helpdeskWebkul -MAIL_PASSWORD=SiM8$GjQCaI)!pTSF^ +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME= +MAIL_PASSWORD= MAIL_ENCRYPTION=tls + PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= From c51c270e5ee7112f4e3d10eea1d5e77864e7d00e Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Wed, 22 Jan 2020 13:37:08 +0530 Subject: [PATCH 29/30] Fixed App URL in --- .env.testing | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.testing b/.env.testing index 0d7ae04d9..b5b8726aa 100644 --- a/.env.testing +++ b/.env.testing @@ -3,7 +3,7 @@ APP_ENV=local APP_VERSION=0.1.5 APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE= APP_DEBUG=true -APP_URL=http://192.168.15.195/laravel/bagisto/public +APP_URL=http://localhost LOG_CHANNEL=stack @@ -40,5 +40,5 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" -SHOP_MAIL_FROM=jitendra@webkul.com -ADMIN_MAIL_TO=jitendra@webkul.com \ No newline at end of file +SHOP_MAIL_FROM=test@example.com +ADMIN_MAIL_TO=test@example.com \ No newline at end of file From 80a2ddb88d9de0b981d824970e3c69355c6ecc31 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Wed, 22 Jan 2020 14:58:39 +0530 Subject: [PATCH 30/30] Issue #1397 fixed --- .../Webkul/Admin/src/Resources/views/account/edit.blade.php | 2 +- .../src/Resources/views/users/reset-password/create.blade.php | 2 +- .../Admin/src/Resources/views/users/users/create.blade.php | 2 +- .../Webkul/Admin/src/Resources/views/users/users/edit.blade.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/Webkul/Admin/src/Resources/views/account/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/account/edit.blade.php index 517c6a005..e6f40f89e 100755 --- a/packages/Webkul/Admin/src/Resources/views/account/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/account/edit.blade.php @@ -48,7 +48,7 @@
- + @{{ errors.first('password') }}
diff --git a/packages/Webkul/Admin/src/Resources/views/users/reset-password/create.blade.php b/packages/Webkul/Admin/src/Resources/views/users/reset-password/create.blade.php index bcd1caeac..5cb7b85ce 100755 --- a/packages/Webkul/Admin/src/Resources/views/users/reset-password/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/users/reset-password/create.blade.php @@ -38,7 +38,7 @@
- + @{{ errors.first('password') }}
diff --git a/packages/Webkul/Admin/src/Resources/views/users/users/create.blade.php b/packages/Webkul/Admin/src/Resources/views/users/users/create.blade.php index 793c2c0e5..a7bf810c3 100755 --- a/packages/Webkul/Admin/src/Resources/views/users/users/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/users/users/create.blade.php @@ -47,7 +47,7 @@
- + @{{ errors.first('password') }}
diff --git a/packages/Webkul/Admin/src/Resources/views/users/users/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/users/users/edit.blade.php index 72f3b3b29..61d6c7716 100755 --- a/packages/Webkul/Admin/src/Resources/views/users/users/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/users/users/edit.blade.php @@ -48,7 +48,7 @@
- + @{{ errors.first('password') }}