From 8e3c43bd19bd8d0a6cf065621c6112014eb70c68 Mon Sep 17 00:00:00 2001 From: Abdullah Al-Faqeir Date: Wed, 6 Oct 2021 15:26:08 +0300 Subject: [PATCH] - Fixing coding style. - Fixing typo. --- database/factories/UserFactory.php | 6 +- .../API/Http/Resources/Catalog/Attribute.php | 5 +- .../Resources/Catalog/AttributeOption.php | 5 +- .../Attribute/src/Models/AttributeOption.php | 2 +- .../Providers/AttributeServiceProvider.php | 2 - .../BookingProductServiceProvider.php | 2 - .../Database/Factories/CategoryFactory.php | 4 +- .../src/Models/CategoryTranslation.php | 2 - .../Database/Factories/CartAddressFactory.php | 6 +- .../src/Database/Factories/CartFactory.php | 30 +- .../Database/Factories/CartItemFactory.php | 14 +- .../src/Providers/CheckoutServiceProvider.php | 6 +- packages/Webkul/Core/src/Core.php | 2 +- .../Factories/CartRuleCouponFactory.php | 10 +- .../Database/Factories/CartRuleFactory.php | 36 +- .../src/Database/Factories/ChannelFactory.php | 18 +- .../ChannelInventorySourceFactory.php | 2 +- .../src/Database/Factories/LocaleFactory.php | 4 +- .../Factories/SubscriberListFactory.php | 4 +- .../Core/src/Helpers/Laravel5Helper.php | 14 +- packages/Webkul/Core/src/Models/Address.php | 7 +- .../Providers/CoreModuleServiceProvider.php | 2 +- .../src/Providers/CoreServiceProvider.php | 14 +- .../Factories/CustomerAddressFactory.php | 24 +- .../Database/Factories/CustomerFactory.php | 22 +- .../Factories/CustomerGroupFactory.php | 4 +- .../Customer/src/Models/CustomerGroup.php | 3 +- .../src/Providers/CustomerServiceProvider.php | 13 +- .../Factories/InventorySourceFactory.php | 30 +- .../Providers/InventoryServiceProvider.php | 4 +- .../ProductAttributeValueFactory.php | 4 +- .../ProductDownloadableLinkFactory.php | 14 +- ...ductDownloadableLinkTranslationFactory.php | 4 +- .../src/Database/Factories/ProductFactory.php | 2 +- .../Factories/ProductInventoryFactory.php | 4 +- .../Factories/ProductReviewFactory.php | 8 +- .../Database/Seeders/ProductTableSeeder.php | 4 +- .../Product/src/Helpers/GenerateProduct.php | 8 +- .../Webkul/Product/src/Models/Product.php | 2 +- .../src/Models/ProductAttributeValue.php | 20 +- .../src/Providers/ProductServiceProvider.php | 10 +- .../src/Database/Factories/InvoiceFactory.php | 36 +- .../Database/Factories/InvoiceItemFactory.php | 26 +- .../Factories/OrderAddressFactory.php | 24 +- .../src/Database/Factories/OrderFactory.php | 60 +-- .../Database/Factories/OrderItemFactory.php | 28 +- .../Database/Factories/ShipmentFactory.php | 6 +- packages/Webkul/Sales/src/Models/Invoice.php | 4 +- packages/Webkul/Sales/src/Models/Order.php | 42 +- .../Webkul/Sales/src/Models/OrderItem.php | 2 +- .../src/Providers/SalesServiceProvider.php | 6 +- .../Database/Factories/TaxCategoryFactory.php | 4 +- .../src/Database/Factories/TaxMapFactory.php | 2 +- .../src/Database/Factories/TaxRateFactory.php | 14 +- tests/trigger/Shop/DatabaseLogicCest.php | 52 +-- tests/trigger/Shop/TriggerCest.php | 206 ++++----- tests/unit/CartRule/CartRuleCest.php | 429 +++++++++--------- 57 files changed, 641 insertions(+), 677 deletions(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 5ac28a244..9279a5d40 100755 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -13,12 +13,12 @@ namespace Database\Factories; | */ -class UserFactory extends \Illuminate\Database\Eloquent\Factories\Factory -{ +use Illuminate\Database\Eloquent\Factories\Factory; +class UserFactory extends Factory +{ public function definition(): array { return []; } - } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/Attribute.php b/packages/Webkul/API/Http/Resources/Catalog/Attribute.php index 7fb536782..06ba80f5a 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Attribute.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Attribute.php @@ -6,15 +6,13 @@ use Illuminate\Http\Resources\Json\JsonResource; class Attribute extends JsonResource { - /** * Transform the resource into an array. * * @param \Illuminate\Http\Request - * * @return array */ - public function toArray($request) + public function toArray($request): array { return [ 'id' => $this->id, @@ -27,5 +25,4 @@ class Attribute extends JsonResource 'updated_at' => $this->updated_at, ]; } - } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php b/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php index 791e955f0..15c7cca43 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php +++ b/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php @@ -6,15 +6,13 @@ use Illuminate\Http\Resources\Json\JsonResource; class AttributeOption extends JsonResource { - /** * Transform the resource into an array. * * @param \Illuminate\Http\Request - * * @return array */ - public function toArray($request) + public function toArray($request): array { return [ 'id' => $this->id, @@ -23,5 +21,4 @@ class AttributeOption extends JsonResource 'swatch_value' => $this->swatch_value, ]; } - } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Models/AttributeOption.php b/packages/Webkul/Attribute/src/Models/AttributeOption.php index e57d231c2..d99cc8181 100755 --- a/packages/Webkul/Attribute/src/Models/AttributeOption.php +++ b/packages/Webkul/Attribute/src/Models/AttributeOption.php @@ -40,7 +40,7 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra return url('cache/small/' . $this->swatch_value); } - return; + return null; } /** diff --git a/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php b/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php index 17a639e61..cc37ac69b 100755 --- a/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php +++ b/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider; class AttributeServiceProvider extends ServiceProvider { - /** * Bootstrap services. * @@ -16,5 +15,4 @@ class AttributeServiceProvider extends ServiceProvider { $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); } - } \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Providers/BookingProductServiceProvider.php b/packages/Webkul/BookingProduct/src/Providers/BookingProductServiceProvider.php index cf53b167b..56d23a577 100644 --- a/packages/Webkul/BookingProduct/src/Providers/BookingProductServiceProvider.php +++ b/packages/Webkul/BookingProduct/src/Providers/BookingProductServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider; class BookingProductServiceProvider extends ServiceProvider { - /** * Bootstrap services. * @@ -38,5 +37,4 @@ class BookingProductServiceProvider extends ServiceProvider { $this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types'); } - } \ No newline at end of file diff --git a/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php b/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php index 6b8612e99..3c8e36917 100644 --- a/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php +++ b/packages/Webkul/Category/src/Database/Factories/CategoryFactory.php @@ -30,8 +30,8 @@ class CategoryFactory extends Factory public function definition(): array { return [ - 'status' => 1, - 'position' => $this->faker->randomDigit(), + 'status' => 1, + 'position' => $this->faker->randomDigit(), 'parent_id' => 1, ]; } diff --git a/packages/Webkul/Category/src/Models/CategoryTranslation.php b/packages/Webkul/Category/src/Models/CategoryTranslation.php index 621cb3fcb..71ccee2fa 100755 --- a/packages/Webkul/Category/src/Models/CategoryTranslation.php +++ b/packages/Webkul/Category/src/Models/CategoryTranslation.php @@ -14,7 +14,6 @@ use Webkul\Category\Contracts\CategoryTranslation as CategoryTranslationContract */ class CategoryTranslation extends Model implements CategoryTranslationContract { - public $timestamps = false; protected $fillable = [ @@ -26,5 +25,4 @@ class CategoryTranslation extends Model implements CategoryTranslationContract 'meta_keywords', 'locale_id', ]; - } \ No newline at end of file diff --git a/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php b/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php index cb179e9b0..aa2e68423 100644 --- a/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php +++ b/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php @@ -22,9 +22,9 @@ class CartAddressFactory extends Factory public function definition(): array { return [ - 'first_name' => $this->faker->firstName(), - 'last_name' => $this->faker->lastName, - 'email' => $this->faker->email, + 'first_name' => $this->faker->firstName(), + 'last_name' => $this->faker->lastName, + 'email' => $this->faker->email, 'address_type' => CartAddress::ADDRESS_TYPE_BILLING, ]; } diff --git a/packages/Webkul/Checkout/src/Database/Factories/CartFactory.php b/packages/Webkul/Checkout/src/Database/Factories/CartFactory.php index 65e5f46b9..3de690a15 100644 --- a/packages/Webkul/Checkout/src/Database/Factories/CartFactory.php +++ b/packages/Webkul/Checkout/src/Database/Factories/CartFactory.php @@ -35,22 +35,22 @@ class CartFactory extends Factory ->create(); return [ - 'is_guest' => 0, - 'is_active' => 1, - 'customer_id' => $customer->id, - 'customer_email' => $customer->email, - 'customer_first_name' => $customer->first_name, - 'customer_last_name' => $customer->last_name, - 'is_gift' => 0, - 'base_currency_code' => 'EUR', + 'is_guest' => 0, + 'is_active' => 1, + 'customer_id' => $customer->id, + 'customer_email' => $customer->email, + 'customer_first_name' => $customer->first_name, + 'customer_last_name' => $customer->last_name, + 'is_gift' => 0, + 'base_currency_code' => 'EUR', 'channel_currency_code' => 'EUR', - 'grand_total' => 0.0000, - 'base_grand_total' => 0.0000, - 'sub_total' => 0.0000, - 'base_sub_total' => 0.0000, - 'channel_id' => 1, - 'created_at' => $now, - 'updated_at' => $now, + 'grand_total' => 0.0000, + 'base_grand_total' => 0.0000, + 'sub_total' => 0.0000, + 'base_sub_total' => 0.0000, + 'channel_id' => 1, + 'created_at' => $now, + 'updated_at' => $now, ]; } } diff --git a/packages/Webkul/Checkout/src/Database/Factories/CartItemFactory.php b/packages/Webkul/Checkout/src/Database/Factories/CartItemFactory.php index 0ead5b1c4..dbb884c49 100644 --- a/packages/Webkul/Checkout/src/Database/Factories/CartItemFactory.php +++ b/packages/Webkul/Checkout/src/Database/Factories/CartItemFactory.php @@ -38,16 +38,16 @@ class CartItemFactory extends Factory $fallbackPrice = $this->faker->randomFloat(4, 0, 1000); return [ - 'quantity' => 1, - 'sku' => $product->sku, - 'type' => $product->type, - 'name' => $product->name, - 'price' => $product->price ?? $fallbackPrice, + 'quantity' => 1, + 'sku' => $product->sku, + 'type' => $product->type, + 'name' => $product->name, + 'price' => $product->price ?? $fallbackPrice, 'base_price' => $product->price ?? $fallbackPrice, - 'total' => $product->price ?? $fallbackPrice, + 'total' => $product->price ?? $fallbackPrice, 'base_total' => $product->price ?? $fallbackPrice, 'product_id' => $product->id, - 'cart_id' => Cart::factory(), + 'cart_id' => Cart::factory(), 'created_at' => $now, 'updated_at' => $now, ]; diff --git a/packages/Webkul/Checkout/src/Providers/CheckoutServiceProvider.php b/packages/Webkul/Checkout/src/Providers/CheckoutServiceProvider.php index dd4326c0b..011765ec6 100755 --- a/packages/Webkul/Checkout/src/Providers/CheckoutServiceProvider.php +++ b/packages/Webkul/Checkout/src/Providers/CheckoutServiceProvider.php @@ -8,12 +8,11 @@ use Webkul\Checkout\Facades\Cart; class CheckoutServiceProvider extends ServiceProvider { - public function boot(): void { - include __DIR__.'/../Http/helpers.php'; + include __DIR__ . '/../Http/helpers.php'; - $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); $this->app->register(ModuleServiceProvider::class); @@ -49,5 +48,4 @@ class CheckoutServiceProvider extends ServiceProvider $this->app->bind('cart', 'Webkul\Checkout\Cart'); } - } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 49d616478..41f8b0062 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -145,7 +145,7 @@ class Core } /** - * Returns currenct channel models. + * Returns current channel models. * * @return \Webkul\Core\Contracts\Channel */ diff --git a/packages/Webkul/Core/src/Database/Factories/CartRuleCouponFactory.php b/packages/Webkul/Core/src/Database/Factories/CartRuleCouponFactory.php index cbe42b6a1..003106a00 100644 --- a/packages/Webkul/Core/src/Database/Factories/CartRuleCouponFactory.php +++ b/packages/Webkul/Core/src/Database/Factories/CartRuleCouponFactory.php @@ -24,12 +24,12 @@ class CartRuleCouponFactory extends Factory public function definition(): array { return [ - 'code' => Str::uuid(), - 'usage_limit' => 100, + 'code' => Str::uuid(), + 'usage_limit' => 100, 'usage_per_customer' => 100, - 'type' => 0, - 'is_primary' => 1, - 'cart_rule_id' => CartRule::factory(), + 'type' => 0, + 'is_primary' => 1, + 'cart_rule_id' => CartRule::factory(), ]; } } diff --git a/packages/Webkul/Core/src/Database/Factories/CartRuleFactory.php b/packages/Webkul/Core/src/Database/Factories/CartRuleFactory.php index 403654acf..371d5a666 100644 --- a/packages/Webkul/Core/src/Database/Factories/CartRuleFactory.php +++ b/packages/Webkul/Core/src/Database/Factories/CartRuleFactory.php @@ -23,25 +23,25 @@ class CartRuleFactory extends Factory public function definition(): array { return [ - 'name' => Str::uuid(), - 'description' => $this->faker->sentence(), - 'starts_from' => null, - 'ends_till' => null, - 'coupon_type' => '1', - 'use_auto_generation' => '0', - 'usage_per_customer' => '100', - 'uses_per_coupon' => '100', - 'times_used' => '0', - 'condition_type' => '2', - 'end_other_rules' => '0', + 'name' => Str::uuid(), + 'description' => $this->faker->sentence(), + 'starts_from' => null, + 'ends_till' => null, + 'coupon_type' => '1', + 'use_auto_generation' => '0', + 'usage_per_customer' => '100', + 'uses_per_coupon' => '100', + 'times_used' => '0', + 'condition_type' => '2', + 'end_other_rules' => '0', 'uses_attribute_conditions' => '0', - 'discount_quantity' => '0', - 'discount_step' => '0', - 'apply_to_shipping' => '0', - 'free_shipping' => '0', - 'sort_order' => '0', - 'status' => '1', - 'conditions' => null, + 'discount_quantity' => '0', + 'discount_step' => '0', + 'apply_to_shipping' => '0', + 'free_shipping' => '0', + 'sort_order' => '0', + 'status' => '1', + 'conditions' => null, ]; } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Factories/ChannelFactory.php b/packages/Webkul/Core/src/Database/Factories/ChannelFactory.php index ab6ab1574..8df7f7b72 100644 --- a/packages/Webkul/Core/src/Database/Factories/ChannelFactory.php +++ b/packages/Webkul/Core/src/Database/Factories/ChannelFactory.php @@ -26,23 +26,23 @@ class ChannelFactory extends Factory */ public function definition(): array { - $seoTitle = $this->faker->word; + $seoTitle = $this->faker->word; $seoDescription = $this->faker->words(10, true); - $seoKeywords = $this->faker->words(3, true); + $seoKeywords = $this->faker->words(3, true); $seoData = [ - 'meta_title' => $seoTitle, + 'meta_title' => $seoTitle, 'meta_description' => $seoDescription, - 'meta_keywords' => $seoKeywords, + 'meta_keywords' => $seoKeywords, ]; return [ - 'code' => $this->faker->unique()->word, - 'name' => $this->faker->word, + 'code' => $this->faker->unique()->word, + 'name' => $this->faker->word, 'default_locale_id' => Locale::factory(), - 'base_currency_id' => Currency::factory(), - 'root_category_id' => Category::factory(), - 'home_seo' => json_encode($seoData, JSON_THROW_ON_ERROR), + 'base_currency_id' => Currency::factory(), + 'root_category_id' => Category::factory(), + 'home_seo' => json_encode($seoData, JSON_THROW_ON_ERROR), ]; } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Factories/ChannelInventorySourceFactory.php b/packages/Webkul/Core/src/Database/Factories/ChannelInventorySourceFactory.php index 0ddce3c49..c8e8e0f57 100644 --- a/packages/Webkul/Core/src/Database/Factories/ChannelInventorySourceFactory.php +++ b/packages/Webkul/Core/src/Database/Factories/ChannelInventorySourceFactory.php @@ -21,7 +21,7 @@ class ChannelInventorySourceFactory extends Factory public function definition(): array { return [ - 'channel_id' => core()->getCurrentChannel()->id, + 'channel_id' => core()->getCurrentChannel()->id, 'inventory_source_id' => 1, ]; } diff --git a/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php b/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php index 251632861..c612d6054 100644 --- a/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php +++ b/packages/Webkul/Core/src/Database/Factories/LocaleFactory.php @@ -35,8 +35,8 @@ class LocaleFactory extends Factory ->exists()); return [ - 'code' => $languageCode, - 'name' => $this->faker->country, + 'code' => $languageCode, + 'name' => $this->faker->country, 'direction' => 'ltr', ]; } diff --git a/packages/Webkul/Core/src/Database/Factories/SubscriberListFactory.php b/packages/Webkul/Core/src/Database/Factories/SubscriberListFactory.php index 8d13426a1..5aab67eb7 100644 --- a/packages/Webkul/Core/src/Database/Factories/SubscriberListFactory.php +++ b/packages/Webkul/Core/src/Database/Factories/SubscriberListFactory.php @@ -22,9 +22,9 @@ class SubscriberListFactory extends Factory public function definition(): array { return [ - 'email' => $this->faker->safeEmail, + 'email' => $this->faker->safeEmail, 'is_subscribed' => $this->faker->boolean, - 'channel_id' => 1, + 'channel_id' => 1, ]; } } diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php index 7770da7f5..d8d57d5c5 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -32,7 +32,6 @@ use Webkul\Product\Models\ProductDownloadableLinkTranslation; */ class Laravel5Helper extends Laravel { - public const SIMPLE_PRODUCT = 1; public const VIRTUAL_PRODUCT = 2; @@ -89,10 +88,10 @@ class Laravel5Helper extends Laravel if (isset($options['payment_method']) && $options['payment_method'] === 'free_of_charge') { - $grand_total = '0.0000'; + $grand_total = '0.0000'; $base_grand_total = '0.0000'; } else { - $grand_total = (string) $faker->numberBetween(1, 666); + $grand_total = (string)$faker->numberBetween(1, 666); $base_grand_total = $grand_total; } @@ -133,7 +132,7 @@ class Laravel5Helper extends Laravel // actually set the cart to the user's session // when in an functional test: - $stub = new StdClass(); + $stub = new StdClass(); $stub->id = $cart->id; $I->setSession(['cart' => $stub]); @@ -295,7 +294,7 @@ class Laravel5Helper extends Laravel private function createDownloadableLink(int $productId): void { - $I = $this; + $I = $this; $link = $I->have(ProductDownloadableLink::class, [ 'product_id' => $productId, ]); @@ -307,7 +306,7 @@ class Laravel5Helper extends Laravel private function createBookingEventProduct(int $productId): void { - $I = $this; + $I = $this; $bookingProduct = $I->have(BookingProduct::class, [ 'product_id' => $productId, ]); @@ -392,7 +391,7 @@ class Laravel5Helper extends Laravel */ private function appendAttributeDependencies(string $attributeCode, array $data): array { - $locale = core()->getCurrentLocale()->code; + $locale = core()->getCurrentLocale()->code; $channel = core()->getCurrentChannelCode(); $attributeSetDependencies = [ @@ -451,5 +450,4 @@ class Laravel5Helper extends Laravel return $data; } - } diff --git a/packages/Webkul/Core/src/Models/Address.php b/packages/Webkul/Core/src/Models/Address.php index d47a5ce85..d0bb8e5e3 100644 --- a/packages/Webkul/Core/src/Models/Address.php +++ b/packages/Webkul/Core/src/Models/Address.php @@ -1,9 +1,7 @@ first_name.' '.$this->last_name; + return $this->first_name . ' ' . $this->last_name; } /** @@ -92,5 +88,4 @@ abstract class Address extends Model implements AddressContract { return $this->belongsTo(Customer::class); } - } diff --git a/packages/Webkul/Core/src/Providers/CoreModuleServiceProvider.php b/packages/Webkul/Core/src/Providers/CoreModuleServiceProvider.php index fa30ba040..a366f4b29 100644 --- a/packages/Webkul/Core/src/Providers/CoreModuleServiceProvider.php +++ b/packages/Webkul/Core/src/Providers/CoreModuleServiceProvider.php @@ -6,7 +6,7 @@ use Konekt\Concord\BaseModuleServiceProvider; class CoreModuleServiceProvider extends BaseModuleServiceProvider { - public function boot() + public function boot(): void { if ($this->areMigrationsEnabled()) { $this->registerMigrations(); diff --git a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php index 53307552f..f6c961d3a 100755 --- a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php +++ b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php @@ -17,7 +17,6 @@ use Webkul\Theme\ViewRenderEventManager; class CoreServiceProvider extends ServiceProvider { - /** * Bootstrap services. * @@ -25,11 +24,11 @@ class CoreServiceProvider extends ServiceProvider */ public function boot(): void { - include __DIR__.'/../Http/helpers.php'; + include __DIR__ . '/../Http/helpers.php'; - $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); - $this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'core'); + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'core'); Validator::extend('slug', 'Webkul\Core\Contracts\Validations\Slug@passes'); @@ -38,15 +37,15 @@ class CoreServiceProvider extends ServiceProvider Validator::extend('decimal', 'Webkul\Core\Contracts\Validations\Decimal@passes'); $this->publishes([ - dirname(__DIR__).'/Config/concord.php' => config_path('concord.php'), - dirname(__DIR__).'/Config/scout.php' => config_path('scout.php'), + dirname(__DIR__) . '/Config/concord.php' => config_path('concord.php'), + dirname(__DIR__) . '/Config/scout.php' => config_path('scout.php'), ]); $this->app->bind(ExceptionHandler::class, Handler::class); SliderProxy::observe(SliderObserver::class); - $this->loadViewsFrom(__DIR__.'/../Resources/views', 'core'); + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'core'); Event::listen('bagisto.shop.layout.body.after', static function (ViewRenderEventManager $viewRenderEventManager) { $viewRenderEventManager->addTemplate('core::blade.tracer.style'); @@ -127,5 +126,4 @@ class CoreServiceProvider extends ServiceProvider return new BladeCompiler($app['files'], $app['config']['view.compiled']); }); } - } diff --git a/packages/Webkul/Customer/src/Database/Factories/CustomerAddressFactory.php b/packages/Webkul/Customer/src/Database/Factories/CustomerAddressFactory.php index 5b2e0e487..4c0f3875c 100644 --- a/packages/Webkul/Customer/src/Database/Factories/CustomerAddressFactory.php +++ b/packages/Webkul/Customer/src/Database/Factories/CustomerAddressFactory.php @@ -27,22 +27,22 @@ class CustomerAddressFactory extends Factory $fakerIt = \Faker\Factory::create('it_IT'); return [ - 'customer_id' => Customer::factory(), - 'company_name' => $this->faker->company, - 'vat_id' => $fakerIt->vatId(), - 'first_name' => $this->faker->firstName, - 'last_name' => $this->faker->lastName, - 'address1' => $this->faker->streetAddress, - 'country' => $this->faker->countryCode, - 'state' => $this->faker->state, - 'city' => $this->faker->city, - 'postcode' => $this->faker->postcode, - 'phone' => $this->faker->e164PhoneNumber, + 'customer_id' => Customer::factory(), + 'company_name' => $this->faker->company, + 'vat_id' => $fakerIt->vatId(), + 'first_name' => $this->faker->firstName, + 'last_name' => $this->faker->lastName, + 'address1' => $this->faker->streetAddress, + 'country' => $this->faker->countryCode, + 'state' => $this->faker->state, + 'city' => $this->faker->city, + 'postcode' => $this->faker->postcode, + 'phone' => $this->faker->e164PhoneNumber, 'default_address' => Arr::random([ 0, 1, ]), - 'address_type' => CustomerAddress::ADDRESS_TYPE, + 'address_type' => CustomerAddress::ADDRESS_TYPE, ]; } } diff --git a/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php b/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php index cccfc9002..626889829 100644 --- a/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php +++ b/packages/Webkul/Customer/src/Database/Factories/CustomerFactory.php @@ -32,25 +32,25 @@ class CustomerFactory extends Factory */ public function definition(): array { - $now = date("Y-m-d H:i:s"); + $now = date("Y-m-d H:i:s"); $password = $this->faker->password; return [ - 'first_name' => $this->faker->firstName(), - 'last_name' => $this->faker->lastName, - 'gender' => Arr::random([ + 'first_name' => $this->faker->firstName(), + 'last_name' => $this->faker->lastName, + 'gender' => Arr::random([ 'male', 'female', 'other', ]), - 'email' => $this->faker->email, - 'status' => 1, - 'password' => Hash::make($password), + 'email' => $this->faker->email, + 'status' => 1, + 'password' => Hash::make($password), 'customer_group_id' => 2, - 'is_verified' => 1, - 'created_at' => $now, - 'updated_at' => $now, - 'notes' => json_encode(['plain_password' => $password], JSON_THROW_ON_ERROR), + 'is_verified' => 1, + 'created_at' => $now, + 'updated_at' => $now, + 'notes' => json_encode(['plain_password' => $password], JSON_THROW_ON_ERROR), ]; } diff --git a/packages/Webkul/Customer/src/Database/Factories/CustomerGroupFactory.php b/packages/Webkul/Customer/src/Database/Factories/CustomerGroupFactory.php index 5fc1bf625..f0c0eb1b9 100644 --- a/packages/Webkul/Customer/src/Database/Factories/CustomerGroupFactory.php +++ b/packages/Webkul/Customer/src/Database/Factories/CustomerGroupFactory.php @@ -25,9 +25,9 @@ class CustomerGroupFactory extends Factory $name = ucfirst($this->faker->word); return [ - 'name' => $name, + 'name' => $name, 'is_user_defined' => $this->faker->boolean, - 'code' => lcfirst($name), + 'code' => lcfirst($name), ]; } } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Models/CustomerGroup.php b/packages/Webkul/Customer/src/Models/CustomerGroup.php index 87a0ef940..421e72dcd 100755 --- a/packages/Webkul/Customer/src/Models/CustomerGroup.php +++ b/packages/Webkul/Customer/src/Models/CustomerGroup.php @@ -3,6 +3,7 @@ namespace Webkul\Customer\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Factories\HasFactory; use Webkul\Customer\Database\Factories\CustomerGroupFactory; use Webkul\Customer\Contracts\CustomerGroup as CustomerGroupContract; @@ -22,7 +23,7 @@ class CustomerGroup extends Model implements CustomerGroupContract /** * Get the customers for this group. */ - public function customers(): \Illuminate\Database\Eloquent\Relations\HasMany + public function customers(): HasMany { return $this->hasMany(CustomerProxy::modelClass()); } diff --git a/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php b/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php index b95331374..28c31b549 100755 --- a/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php +++ b/packages/Webkul/Customer/src/Providers/CustomerServiceProvider.php @@ -10,21 +10,21 @@ use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer; class CustomerServiceProvider extends ServiceProvider { - /** * Bootstrap application services. * + * @param \Illuminate\Routing\Router $router * @return void */ - public function boot(Router $router) + public function boot(Router $router): void { $router->aliasMiddleware('customer', RedirectIfNotCustomer::class); - $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); - $this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'customer'); + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customer'); - $this->loadViewsFrom(__DIR__.'/../Resources/views', 'customer'); + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'customer'); $this->app['validator']->extend('captcha', function ($attribute, $value, $parameters) { return $this->app['captcha']->validateResponse($value); @@ -52,7 +52,6 @@ class CustomerServiceProvider extends ServiceProvider */ protected function registerConfig(): void { - $this->mergeConfigFrom(dirname(__DIR__).'/Config/system.php', 'core'); + $this->mergeConfigFrom(dirname(__DIR__) . '/Config/system.php', 'core'); } - } diff --git a/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php b/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php index 74d5ee111..0143ab020 100644 --- a/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php +++ b/packages/Webkul/Inventory/src/Database/Factories/InventorySourceFactory.php @@ -21,24 +21,24 @@ class InventorySourceFactory extends Factory */ public function definition(): array { - $now = date("Y-m-d H:i:s"); + $now = date("Y-m-d H:i:s"); $code = $this->faker->unique()->word; return [ - 'code' => $this->faker->unique()->word, - 'name' => $code, - 'description' => $this->faker->sentence, - 'contact_name' => $this->faker->name, - 'contact_email' => $this->faker->safeEmail, + 'code' => $this->faker->unique()->word, + 'name' => $code, + 'description' => $this->faker->sentence, + 'contact_name' => $this->faker->name, + 'contact_email' => $this->faker->safeEmail, 'contact_number' => $this->faker->phoneNumber, - 'country' => $this->faker->countryCode, - 'state' => $this->faker->state, - 'city' => $this->faker->city, - 'street' => $this->faker->streetAddress, - 'postcode' => $this->faker->postcode, - 'priority' => 0, - 'status' => 1, - 'created_at' => $now, - 'updated_at' => $now, + 'country' => $this->faker->countryCode, + 'state' => $this->faker->state, + 'city' => $this->faker->city, + 'street' => $this->faker->streetAddress, + 'postcode' => $this->faker->postcode, + 'priority' => 0, + 'status' => 1, + 'created_at' => $now, + 'updated_at' => $now, ]; } } diff --git a/packages/Webkul/Inventory/src/Providers/InventoryServiceProvider.php b/packages/Webkul/Inventory/src/Providers/InventoryServiceProvider.php index 2e10fed18..035fc1476 100755 --- a/packages/Webkul/Inventory/src/Providers/InventoryServiceProvider.php +++ b/packages/Webkul/Inventory/src/Providers/InventoryServiceProvider.php @@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider; class InventoryServiceProvider extends ServiceProvider { - /** * Bootstrap services. * @@ -14,7 +13,7 @@ class InventoryServiceProvider extends ServiceProvider */ public function boot(): void { - $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); } /** @@ -25,5 +24,4 @@ class InventoryServiceProvider extends ServiceProvider public function register(): void { } - } \ 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 index 3b0737799..67e4d0f0b 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductAttributeValueFactory.php @@ -24,8 +24,8 @@ class ProductAttributeValueFactory extends Factory { return [ //'product_id' => Product::factory(), - 'locale' => 'en', - 'channel' => 'default', + 'locale' => 'en', + 'channel' => 'default', ]; } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkFactory.php index 9d29062b1..d088ef3fd 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkFactory.php @@ -22,17 +22,17 @@ class ProductDownloadableLinkFactory extends Factory */ public function definition(): array { - $now = date("Y-m-d H:i:s"); + $now = date("Y-m-d H:i:s"); $filename = 'ProductImageExampleForUpload.jpg'; $filepath = '/tests/_data/'; return [ - 'url' => '', - 'file' => $filepath . $filename, - 'file_name' => $filename, - 'type' => 'file', - 'price' => 0.0000, - 'downloads' => $this->faker->randomNumber(1), + 'url' => '', + 'file' => $filepath . $filename, + 'file_name' => $filename, + 'type' => 'file', + 'price' => 0.0000, + 'downloads' => $this->faker->randomNumber(1), 'product_id' => Product::factory(), 'created_at' => $now, 'updated_at' => $now, diff --git a/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkTranslationFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkTranslationFactory.php index c42c64a29..7a01705b4 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkTranslationFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductDownloadableLinkTranslationFactory.php @@ -23,8 +23,8 @@ class ProductDownloadableLinkTranslationFactory extends Factory public function definition(): array { return [ - 'locale' => 'en', - 'title' => $this->faker->word, + 'locale' => 'en', + 'title' => $this->faker->word, 'product_downloadable_link_id' => ProductDownloadableLink::factory(), ]; } diff --git a/packages/Webkul/Product/src/Database/Factories/ProductFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductFactory.php index fde6b3bcb..207434b30 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductFactory.php @@ -32,7 +32,7 @@ class ProductFactory extends Factory public function definition(): array { return [ - 'sku' => $this->faker->uuid, + 'sku' => $this->faker->uuid, 'attribute_family_id' => 1, ]; } diff --git a/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php index b39a2c7c2..d2fce80d9 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductInventoryFactory.php @@ -24,8 +24,8 @@ class ProductInventoryFactory extends Factory public function definition(): array { return [ - 'qty' => $this->faker->numberBetween(100, 200), - 'product_id' => Product::factory(), + 'qty' => $this->faker->numberBetween(100, 200), + 'product_id' => Product::factory(), 'inventory_source_id' => InventorySource::factory(), ]; } diff --git a/packages/Webkul/Product/src/Database/Factories/ProductReviewFactory.php b/packages/Webkul/Product/src/Database/Factories/ProductReviewFactory.php index c19bf3844..b23f76856 100644 --- a/packages/Webkul/Product/src/Database/Factories/ProductReviewFactory.php +++ b/packages/Webkul/Product/src/Database/Factories/ProductReviewFactory.php @@ -23,10 +23,10 @@ class ProductReviewFactory extends Factory public function definition(): array { return [ - 'title' => $this->faker->words(5, true), - 'rating' => $this->faker->numberBetween(0, 10), - 'status' => 1, - 'comment' => $this->faker->sentence(20), + 'title' => $this->faker->words(5, true), + 'rating' => $this->faker->numberBetween(0, 10), + 'status' => 1, + 'comment' => $this->faker->sentence(20), 'product_id' => Product::factory(), ]; } diff --git a/packages/Webkul/Product/src/Database/Seeders/ProductTableSeeder.php b/packages/Webkul/Product/src/Database/Seeders/ProductTableSeeder.php index 147530b74..198852bf8 100755 --- a/packages/Webkul/Product/src/Database/Seeders/ProductTableSeeder.php +++ b/packages/Webkul/Product/src/Database/Seeders/ProductTableSeeder.php @@ -1,13 +1,13 @@ checkRequestedLocaleCodeInRequestedChannel(); + $locale = core()->checkRequestedLocaleCodeInRequestedChannel(); $channel = core()->getRequestedChannelCode(); if (array_key_exists($this->id, self::$loadedAttributeValues) diff --git a/packages/Webkul/Product/src/Models/ProductAttributeValue.php b/packages/Webkul/Product/src/Models/ProductAttributeValue.php index 417c503dd..f9ba4b709 100755 --- a/packages/Webkul/Product/src/Models/ProductAttributeValue.php +++ b/packages/Webkul/Product/src/Models/ProductAttributeValue.php @@ -26,17 +26,17 @@ class ProductAttributeValue extends Model implements ProductAttributeValueContra * @var array */ public static $attributeTypeFields = [ - 'text' => 'text_value', - 'textarea' => 'text_value', - 'price' => 'float_value', - 'boolean' => 'boolean_value', - 'select' => 'integer_value', + 'text' => 'text_value', + 'textarea' => 'text_value', + 'price' => 'float_value', + 'boolean' => 'boolean_value', + 'select' => 'integer_value', 'multiselect' => 'text_value', - 'datetime' => 'datetime_value', - 'date' => 'date_value', - 'file' => 'text_value', - 'image' => 'text_value', - 'checkbox' => 'text_value', + 'datetime' => 'datetime_value', + 'date' => 'date_value', + 'file' => 'text_value', + 'image' => 'text_value', + 'checkbox' => 'text_value', ]; /** diff --git a/packages/Webkul/Product/src/Providers/ProductServiceProvider.php b/packages/Webkul/Product/src/Providers/ProductServiceProvider.php index 745a683eb..dea148022 100755 --- a/packages/Webkul/Product/src/Providers/ProductServiceProvider.php +++ b/packages/Webkul/Product/src/Providers/ProductServiceProvider.php @@ -15,7 +15,6 @@ use Webkul\Product\ProductVideo; class ProductServiceProvider extends ServiceProvider { - /** * Bootstrap services. * @@ -23,14 +22,14 @@ class ProductServiceProvider extends ServiceProvider */ public function boot(): void { - include __DIR__.'/../Http/helpers.php'; + include __DIR__ . '/../Http/helpers.php'; - $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); $this->app->register(EventServiceProvider::class); $this->publishes([ - dirname(__DIR__).'/Config/imagecache.php' => config_path('imagecache.php'), + dirname(__DIR__) . '/Config/imagecache.php' => config_path('imagecache.php'), ]); ProductProxy::observe(ProductObserver::class); @@ -57,7 +56,7 @@ class ProductServiceProvider extends ServiceProvider */ public function registerConfig(): void { - $this->mergeConfigFrom(dirname(__DIR__).'/Config/product_types.php', 'product_types'); + $this->mergeConfigFrom(dirname(__DIR__) . '/Config/product_types.php', 'product_types'); } /** @@ -97,5 +96,4 @@ class ProductServiceProvider extends ServiceProvider return app()->make(ProductVideo::class); }); } - } \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Database/Factories/InvoiceFactory.php b/packages/Webkul/Sales/src/Database/Factories/InvoiceFactory.php index d37f6ef59..1c6634336 100644 --- a/packages/Webkul/Sales/src/Database/Factories/InvoiceFactory.php +++ b/packages/Webkul/Sales/src/Database/Factories/InvoiceFactory.php @@ -32,9 +32,9 @@ class InvoiceFactory extends Factory */ public function definition(): array { - $subTotal = $this->faker->randomFloat(2); + $subTotal = $this->faker->randomFloat(2); $shippingAmount = $this->faker->randomFloat(2); - $taxAmount = $this->faker->randomFloat(2); + $taxAmount = $this->faker->randomFloat(2); if (!isset($attributes['order_id'])) { $attributes['order_id'] = Order::factory(); @@ -45,23 +45,23 @@ class InvoiceFactory extends Factory } return [ - 'email_sent' => 0, - 'total_qty' => $this->faker->randomNumber(), - 'base_currency_code' => 'EUR', + 'email_sent' => 0, + 'total_qty' => $this->faker->randomNumber(), + 'base_currency_code' => 'EUR', 'channel_currency_code' => 'EUR', - 'order_currency_code' => 'EUR', - 'sub_total' => $subTotal, - 'base_sub_total' => $subTotal, - 'grand_total' => $subTotal, - 'base_grand_total' => $subTotal, - 'shipping_amount' => $shippingAmount, - 'base_shipping_amount' => $shippingAmount, - 'tax_amount' => $taxAmount, - 'base_tax_amount' => $taxAmount, - 'discount_amount' => 0, - 'base_discount_amount' => 0, - 'order_id' => $attributes['order_id'], - 'order_address_id' => $attributes['order_address_id'], + 'order_currency_code' => 'EUR', + 'sub_total' => $subTotal, + 'base_sub_total' => $subTotal, + 'grand_total' => $subTotal, + 'base_grand_total' => $subTotal, + 'shipping_amount' => $shippingAmount, + 'base_shipping_amount' => $shippingAmount, + 'tax_amount' => $taxAmount, + 'base_tax_amount' => $taxAmount, + 'discount_amount' => 0, + 'base_discount_amount' => 0, + 'order_id' => $attributes['order_id'], + 'order_address_id' => $attributes['order_address_id'], ]; } diff --git a/packages/Webkul/Sales/src/Database/Factories/InvoiceItemFactory.php b/packages/Webkul/Sales/src/Database/Factories/InvoiceItemFactory.php index 608e9d533..36267a4e5 100644 --- a/packages/Webkul/Sales/src/Database/Factories/InvoiceItemFactory.php +++ b/packages/Webkul/Sales/src/Database/Factories/InvoiceItemFactory.php @@ -24,7 +24,7 @@ class InvoiceItemFactory extends Factory public function definition(): array { $basePrice = $this->faker->randomFloat(2); - $quantity = $this->faker->randomNumber(); + $quantity = $this->faker->randomNumber(); if (!isset($attributes['order_item_id'])) { $attributes['order_item_id'] = OrderItem::factory(); @@ -34,19 +34,19 @@ class InvoiceItemFactory extends Factory ->find($attributes['order_item_id']); return [ - 'name' => $this->faker->word, - 'sku' => $this->faker->unique()->ean13, - 'qty' => $quantity, - 'price' => $basePrice, - 'base_price' => $basePrice, - 'total' => $quantity * $basePrice, - 'base_total' => $quantity * $basePrice, - 'tax_amount' => 0, + 'name' => $this->faker->word, + 'sku' => $this->faker->unique()->ean13, + 'qty' => $quantity, + 'price' => $basePrice, + 'base_price' => $basePrice, + 'total' => $quantity * $basePrice, + 'base_total' => $quantity * $basePrice, + 'tax_amount' => 0, 'base_tax_amount' => 0, - 'product_id' => $orderItem->product_id, - 'product_type' => $orderItem->product_type, - 'order_item_id' => $attributes['order_item_id'], - 'invoice_id' => Invoice::factory(), + 'product_id' => $orderItem->product_id, + 'product_type' => $orderItem->product_type, + 'order_item_id' => $attributes['order_item_id'], + 'invoice_id' => Invoice::factory(), ]; } } diff --git a/packages/Webkul/Sales/src/Database/Factories/OrderAddressFactory.php b/packages/Webkul/Sales/src/Database/Factories/OrderAddressFactory.php index 905343cec..87c3b3375 100644 --- a/packages/Webkul/Sales/src/Database/Factories/OrderAddressFactory.php +++ b/packages/Webkul/Sales/src/Database/Factories/OrderAddressFactory.php @@ -31,23 +31,23 @@ class OrderAddressFactory extends Factory */ public function definition(): array { - $customer = Customer::factory() - ->create(); + $customer = Customer::factory() + ->create(); $customerAddress = CustomerAddress::factory() ->make(); return [ - 'first_name' => $customer->first_name, - 'last_name' => $customer->last_name, - 'email' => $customer->email, - 'address1' => $customerAddress->address1, - 'country' => $customerAddress->country, - 'state' => $customerAddress->state, - 'city' => $customerAddress->city, - 'postcode' => $customerAddress->postcode, - 'phone' => $customerAddress->phone, + 'first_name' => $customer->first_name, + 'last_name' => $customer->last_name, + 'email' => $customer->email, + 'address1' => $customerAddress->address1, + 'country' => $customerAddress->country, + 'state' => $customerAddress->state, + 'city' => $customerAddress->city, + 'postcode' => $customerAddress->postcode, + 'phone' => $customerAddress->phone, 'address_type' => OrderAddress::ADDRESS_TYPE_BILLING, - 'order_id' => Order::factory(), + 'order_id' => Order::factory(), ]; } diff --git a/packages/Webkul/Sales/src/Database/Factories/OrderFactory.php b/packages/Webkul/Sales/src/Database/Factories/OrderFactory.php index 26dbf6ef2..93b57407b 100644 --- a/packages/Webkul/Sales/src/Database/Factories/OrderFactory.php +++ b/packages/Webkul/Sales/src/Database/Factories/OrderFactory.php @@ -43,38 +43,38 @@ class OrderFactory extends Factory ->create(); return [ - 'increment_id' => $lastOrder + 1, - 'status' => 'pending', - 'channel_name' => 'Default', - 'is_guest' => 0, - 'customer_id' => $customer->id, - 'customer_email' => $customer->email, - 'customer_first_name' => $customer->first_name, - 'customer_last_name' => $customer->last_name, - 'is_gift' => 0, - 'total_item_count' => 1, - 'total_qty_ordered' => 1, - 'base_currency_code' => 'EUR', - 'channel_currency_code' => 'EUR', - 'order_currency_code' => 'EUR', - 'grand_total' => 0.0000, - 'base_grand_total' => 0.0000, - 'grand_total_invoiced' => 0.0000, + 'increment_id' => $lastOrder + 1, + 'status' => 'pending', + 'channel_name' => 'Default', + 'is_guest' => 0, + 'customer_id' => $customer->id, + 'customer_email' => $customer->email, + 'customer_first_name' => $customer->first_name, + 'customer_last_name' => $customer->last_name, + 'is_gift' => 0, + 'total_item_count' => 1, + 'total_qty_ordered' => 1, + 'base_currency_code' => 'EUR', + 'channel_currency_code' => 'EUR', + 'order_currency_code' => 'EUR', + 'grand_total' => 0.0000, + 'base_grand_total' => 0.0000, + 'grand_total_invoiced' => 0.0000, 'base_grand_total_invoiced' => 0.0000, - 'grand_total_refunded' => 0.0000, + 'grand_total_refunded' => 0.0000, 'base_grand_total_refunded' => 0.0000, - 'sub_total' => 0.0000, - 'base_sub_total' => 0.0000, - 'sub_total_invoiced' => 0.0000, - 'base_sub_total_invoiced' => 0.0000, - 'sub_total_refunded' => 0.0000, - 'base_sub_total_refunded' => 0.0000, - 'customer_type' => Customer::class, - 'channel_id' => 1, - 'channel_type' => Channel::class, - 'cart_id' => 0, - 'shipping_method' => 'free_free', - 'shipping_title' => 'Free Shipping', + 'sub_total' => 0.0000, + 'base_sub_total' => 0.0000, + 'sub_total_invoiced' => 0.0000, + 'base_sub_total_invoiced' => 0.0000, + 'sub_total_refunded' => 0.0000, + 'base_sub_total_refunded' => 0.0000, + 'customer_type' => Customer::class, + 'channel_id' => 1, + 'channel_type' => Channel::class, + 'cart_id' => 0, + 'shipping_method' => 'free_free', + 'shipping_title' => 'Free Shipping', ]; } diff --git a/packages/Webkul/Sales/src/Database/Factories/OrderItemFactory.php b/packages/Webkul/Sales/src/Database/Factories/OrderItemFactory.php index 129106ac9..1920eb584 100644 --- a/packages/Webkul/Sales/src/Database/Factories/OrderItemFactory.php +++ b/packages/Webkul/Sales/src/Database/Factories/OrderItemFactory.php @@ -38,23 +38,23 @@ class OrderItemFactory extends Factory $fallbackPrice = $this->faker->randomFloat(4, 0, 1000); return [ - 'sku' => $product->sku, - 'type' => $product->type, - 'name' => $product->name, - 'price' => $product->price ?? $fallbackPrice, - 'base_price' => $product->price ?? $fallbackPrice, - 'total' => $product->price ?? $fallbackPrice, - 'base_total' => $product->price ?? $fallbackPrice, - 'product_id' => $product->id, - 'qty_ordered' => 1, - 'qty_shipped' => 0, + 'sku' => $product->sku, + 'type' => $product->type, + 'name' => $product->name, + 'price' => $product->price ?? $fallbackPrice, + 'base_price' => $product->price ?? $fallbackPrice, + 'total' => $product->price ?? $fallbackPrice, + 'base_total' => $product->price ?? $fallbackPrice, + 'product_id' => $product->id, + 'qty_ordered' => 1, + 'qty_shipped' => 0, 'qty_invoiced' => 0, 'qty_canceled' => 0, 'qty_refunded' => 0, - 'additional' => [], - 'order_id' => Order::factory(), - 'created_at' => $now, - 'updated_at' => $now, + 'additional' => [], + 'order_id' => Order::factory(), + 'created_at' => $now, + 'updated_at' => $now, 'product_type' => Product::class, ]; } diff --git a/packages/Webkul/Sales/src/Database/Factories/ShipmentFactory.php b/packages/Webkul/Sales/src/Database/Factories/ShipmentFactory.php index d59b66c40..81b00d53c 100644 --- a/packages/Webkul/Sales/src/Database/Factories/ShipmentFactory.php +++ b/packages/Webkul/Sales/src/Database/Factories/ShipmentFactory.php @@ -27,9 +27,9 @@ class ShipmentFactory extends Factory ->create(); return [ - 'total_qty' => $this->faker->numberBetween(1, 20), - 'order_id' => $address->order_id, - 'order_address_id' => $address->id, + 'total_qty' => $this->faker->numberBetween(1, 20), + 'order_id' => $address->order_id, + 'order_address_id' => $address->id, 'inventory_source_id' => InventorySource::factory(), ]; } diff --git a/packages/Webkul/Sales/src/Models/Invoice.php b/packages/Webkul/Sales/src/Models/Invoice.php index 98c6226ab..0303aafb0 100755 --- a/packages/Webkul/Sales/src/Models/Invoice.php +++ b/packages/Webkul/Sales/src/Models/Invoice.php @@ -32,8 +32,8 @@ class Invoice extends Model implements InvoiceContract * @var array */ protected $statusLabel = [ - 'pending' => 'Pending', - 'paid' => 'Paid', + 'pending' => 'Pending', + 'paid' => 'Paid', 'refunded' => 'Refunded', ]; diff --git a/packages/Webkul/Sales/src/Models/Order.php b/packages/Webkul/Sales/src/Models/Order.php index 13b58b7b3..2b21ba4f4 100755 --- a/packages/Webkul/Sales/src/Models/Order.php +++ b/packages/Webkul/Sales/src/Models/Order.php @@ -6,6 +6,10 @@ use Webkul\Checkout\Models\CartProxy; use Illuminate\Database\Eloquent\Model; use Webkul\Sales\Contracts\Order as OrderContract; use Webkul\Sales\Database\Factories\OrderFactory; +use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\MorphTo; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; class Order extends Model implements OrderContract @@ -39,13 +43,13 @@ class Order extends Model implements OrderContract ]; protected $statusLabel = [ - self::STATUS_PENDING => 'Pending', + self::STATUS_PENDING => 'Pending', self::STATUS_PENDING_PAYMENT => 'Pending Payment', - self::STATUS_PROCESSING => 'Processing', - self::STATUS_COMPLETED => 'Completed', - self::STATUS_CANCELED => 'Canceled', - self::STATUS_CLOSED => 'Closed', - self::STATUS_FRAUD => 'Fraud', + self::STATUS_PROCESSING => 'Processing', + self::STATUS_COMPLETED => 'Completed', + self::STATUS_CANCELED => 'Canceled', + self::STATUS_CLOSED => 'Closed', + self::STATUS_FRAUD => 'Fraud', ]; /** @@ -83,7 +87,7 @@ class Order extends Model implements OrderContract /** * Get the associated cart that was used to create this order. */ - public function cart(): \Illuminate\Database\Eloquent\Relations\BelongsTo + public function cart(): BelongsTo { return $this->belongsTo(CartProxy::modelClass()); } @@ -91,7 +95,7 @@ class Order extends Model implements OrderContract /** * Get the order items record associated with the order. */ - public function items(): \Illuminate\Database\Eloquent\Relations\HasMany + public function items(): HasMany { return $this->hasMany(OrderItemProxy::modelClass()) ->whereNull('parent_id'); @@ -100,7 +104,7 @@ class Order extends Model implements OrderContract /** * Get the comments record associated with the order. */ - public function comments(): \Illuminate\Database\Eloquent\Relations\HasMany + public function comments(): HasMany { return $this->hasMany(OrderCommentProxy::modelClass()); } @@ -108,7 +112,7 @@ class Order extends Model implements OrderContract /** * Get the order items record associated with the order. */ - public function all_items(): \Illuminate\Database\Eloquent\Relations\HasMany + public function all_items(): HasMany { return $this->hasMany(OrderItemProxy::modelClass()); } @@ -116,7 +120,7 @@ class Order extends Model implements OrderContract /** * Get the order shipments record associated with the order. */ - public function shipments(): \Illuminate\Database\Eloquent\Relations\HasMany + public function shipments(): HasMany { return $this->hasMany(ShipmentProxy::modelClass()); } @@ -124,7 +128,7 @@ class Order extends Model implements OrderContract /** * Get the order invoices record associated with the order. */ - public function invoices(): \Illuminate\Database\Eloquent\Relations\HasMany + public function invoices(): HasMany { return $this->hasMany(InvoiceProxy::modelClass()); } @@ -132,7 +136,7 @@ class Order extends Model implements OrderContract /** * Get the order refunds record associated with the order. */ - public function refunds(): \Illuminate\Database\Eloquent\Relations\HasMany + public function refunds(): HasMany { return $this->hasMany(RefundProxy::modelClass()); } @@ -140,7 +144,7 @@ class Order extends Model implements OrderContract /** * Get the order transactions record associated with the order. */ - public function transactions(): \Illuminate\Database\Eloquent\Relations\HasMany + public function transactions(): HasMany { return $this->hasMany(OrderTransactionProxy::modelClass()); } @@ -148,7 +152,7 @@ class Order extends Model implements OrderContract /** * Get the customer record associated with the order. */ - public function customer(): \Illuminate\Database\Eloquent\Relations\MorphTo + public function customer(): MorphTo { return $this->morphTo(); } @@ -156,7 +160,7 @@ class Order extends Model implements OrderContract /** * Get the addresses for the order. */ - public function addresses(): \Illuminate\Database\Eloquent\Relations\HasMany + public function addresses(): HasMany { return $this->hasMany(OrderAddressProxy::modelClass()); } @@ -164,7 +168,7 @@ class Order extends Model implements OrderContract /** * Get the payment for the order. */ - public function payment(): \Illuminate\Database\Eloquent\Relations\HasOne + public function payment(): HasOne { return $this->hasOne(OrderPaymentProxy::modelClass()); } @@ -172,7 +176,7 @@ class Order extends Model implements OrderContract /** * Get the billing address for the order. */ - public function billing_address(): \Illuminate\Database\Eloquent\Relations\HasMany + public function billing_address(): HasMany { return $this->addresses() ->where('address_type', OrderAddress::ADDRESS_TYPE_BILLING); @@ -190,7 +194,7 @@ class Order extends Model implements OrderContract /** * Get the shipping address for the order. */ - public function shipping_address(): \Illuminate\Database\Eloquent\Relations\HasMany + public function shipping_address(): HasMany { return $this->addresses() ->where('address_type', OrderAddress::ADDRESS_TYPE_SHIPPING); diff --git a/packages/Webkul/Sales/src/Models/OrderItem.php b/packages/Webkul/Sales/src/Models/OrderItem.php index 8593d738a..9feaaed6e 100755 --- a/packages/Webkul/Sales/src/Models/OrderItem.php +++ b/packages/Webkul/Sales/src/Models/OrderItem.php @@ -41,7 +41,7 @@ class OrderItem extends Model implements OrderItemContract return $this->typeInstance; } - $this->typeInstance = app(config('product_types.'.$this->type.'.class')); + $this->typeInstance = app(config('product_types.' . $this->type . '.class')); if ($this->product) { $this->typeInstance->setProduct($this); diff --git a/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php b/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php index f966f91ac..25faf9ba5 100755 --- a/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php +++ b/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php @@ -6,10 +6,9 @@ use Illuminate\Support\ServiceProvider; class SalesServiceProvider extends ServiceProvider { - public function boot(): void { - $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); } /** @@ -19,7 +18,6 @@ class SalesServiceProvider extends ServiceProvider */ public function register(): void { - $this->mergeConfigFrom(dirname(__DIR__).'/Config/system.php', 'core'); + $this->mergeConfigFrom(dirname(__DIR__) . '/Config/system.php', 'core'); } - } \ No newline at end of file diff --git a/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php b/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php index d185fc25d..21fd80b27 100644 --- a/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php +++ b/packages/Webkul/Tax/src/Database/Factories/TaxCategoryFactory.php @@ -22,8 +22,8 @@ class TaxCategoryFactory extends Factory public function definition(): array { return [ - 'code' => $this->faker->uuid, - 'name' => $this->faker->words(2, true), + 'code' => $this->faker->uuid, + 'name' => $this->faker->words(2, true), 'description' => $this->faker->sentence(10), ]; } diff --git a/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php b/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php index de5de85e4..a8cb272ee 100644 --- a/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php +++ b/packages/Webkul/Tax/src/Database/Factories/TaxMapFactory.php @@ -25,7 +25,7 @@ class TaxMapFactory extends Factory { return [ 'tax_category_id' => TaxCategory::factory(), - 'tax_rate_id' => TaxRate::factory(), + 'tax_rate_id' => TaxRate::factory(), ]; } } diff --git a/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php b/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php index 5231cdae3..a37c9eaa1 100644 --- a/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php +++ b/packages/Webkul/Tax/src/Database/Factories/TaxRateFactory.php @@ -23,13 +23,13 @@ class TaxRateFactory extends Factory { return [ 'identifier' => $this->faker->uuid, - 'is_zip' => 0, - 'zip_code' => '*', - 'zip_from' => null, - 'zip_to' => null, - 'state' => '', - 'country' => $this->faker->countryCode, - 'tax_rate' => $this->faker->randomFloat(2, 3, 25), + 'is_zip' => 0, + 'zip_code' => '*', + 'zip_from' => null, + 'zip_to' => null, + 'state' => '', + 'country' => $this->faker->countryCode, + 'tax_rate' => $this->faker->randomFloat(2, 3, 25), ]; } } \ No newline at end of file diff --git a/tests/trigger/Shop/DatabaseLogicCest.php b/tests/trigger/Shop/DatabaseLogicCest.php index d2e96dab9..b325f13f1 100644 --- a/tests/trigger/Shop/DatabaseLogicCest.php +++ b/tests/trigger/Shop/DatabaseLogicCest.php @@ -38,7 +38,7 @@ class DatabaseLogicCest public function testGetUrlPathOfCategory(UnitTester $I) { $rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [ - 'slug' => 'root', + 'slug' => 'root', 'locale' => 'en', ]); @@ -49,20 +49,20 @@ class DatabaseLogicCest $parentCategoryName = $this->faker->word; $parentCategoryAttributes = [ - 'parent_id' => $rootCategory->id, - 'position' => 1, - 'status' => 1, + 'parent_id' => $rootCategory->id, + 'position' => 1, + 'status' => 1, $this->localeEn->code => [ - 'name' => $parentCategoryName, - 'slug' => strtolower($parentCategoryName), + 'name' => $parentCategoryName, + 'slug' => strtolower($parentCategoryName), 'description' => $parentCategoryName, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], $this->localeDe->code => [ - 'name' => $parentCategoryName, - 'slug' => strtolower($parentCategoryName), + 'name' => $parentCategoryName, + 'slug' => strtolower($parentCategoryName), 'description' => $parentCategoryName, - 'locale_id' => $this->localeDe->id, + 'locale_id' => $this->localeDe->id, ], ]; @@ -71,22 +71,22 @@ class DatabaseLogicCest $rootCategory->prependNode($parentCategory); $I->assertNotNull($parentCategory); - $categoryName = $this->faker->word; + $categoryName = $this->faker->word; $categoryAttributes = [ - 'position' => 1, - 'status' => 1, - 'parent_id' => $parentCategory->id, + 'position' => 1, + 'status' => 1, + 'parent_id' => $parentCategory->id, $this->localeEn->code => [ - 'name' => $categoryName, - 'slug' => strtolower($categoryName), + 'name' => $categoryName, + 'slug' => strtolower($categoryName), 'description' => $categoryName, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], $this->localeDe->code => [ - 'name' => $categoryName, - 'slug' => strtolower($categoryName), + 'name' => $categoryName, + 'slug' => strtolower($categoryName), 'description' => $categoryName, - 'locale_id' => $this->localeDe->id, + 'locale_id' => $this->localeDe->id, ], ]; @@ -114,14 +114,14 @@ class DatabaseLogicCest $I->assertEquals($expectedUrlPath, $urlPathQueryResult->url_path); $root2Category = $I->make(Category::class, [ - 'position' => 1, - 'status' => 1, - 'parent_id' => null, + 'position' => 1, + 'status' => 1, + 'parent_id' => null, $this->localeEn->code => [ - 'name' => $this->faker->word, - 'slug' => strtolower($this->faker->word), + 'name' => $this->faker->word, + 'slug' => strtolower($this->faker->word), 'description' => $this->faker->word, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], ]) ->first(); diff --git a/tests/trigger/Shop/TriggerCest.php b/tests/trigger/Shop/TriggerCest.php index 503ff9625..d60505071 100644 --- a/tests/trigger/Shop/TriggerCest.php +++ b/tests/trigger/Shop/TriggerCest.php @@ -48,16 +48,16 @@ class TriggerCest $this->faker = Factory::create(); $rootCategoryTranslation = $I->grabRecord(CategoryTranslation::class, [ - 'slug' => 'root', + 'slug' => 'root', 'locale' => 'en', ]); - $rootCategory = $I->grabRecord(Category::class, [ + $rootCategory = $I->grabRecord(Category::class, [ 'id' => $rootCategoryTranslation->category_id, ]); - $this->parentCategoryName = $this->faker->word; - $this->categoryName = $this->faker->word . $this->faker->randomDigit; - $this->root2CategoryName = $this->faker->word . $this->faker->randomDigit; + $this->parentCategoryName = $this->faker->word; + $this->categoryName = $this->faker->word . $this->faker->randomDigit; + $this->root2CategoryName = $this->faker->word . $this->faker->randomDigit; $this->childOfRoot2CategoryName = $this->faker->word . $this->faker->randomDigit; $this->localeEn = $I->grabRecord(Locale::class, [ @@ -69,20 +69,20 @@ class TriggerCest ]); $this->parentCategoryAttributes = [ - 'parent_id' => $rootCategory->id, - 'position' => 1, - 'status' => 1, + 'parent_id' => $rootCategory->id, + 'position' => 1, + 'status' => 1, $this->localeEn->code => [ - 'name' => $this->parentCategoryName, - 'slug' => strtolower($this->parentCategoryName), + 'name' => $this->parentCategoryName, + 'slug' => strtolower($this->parentCategoryName), 'description' => $this->parentCategoryName, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], $this->localeDe->code => [ - 'name' => $this->parentCategoryName, - 'slug' => strtolower($this->parentCategoryName), + 'name' => $this->parentCategoryName, + 'slug' => strtolower($this->parentCategoryName), 'description' => $this->parentCategoryName, - 'locale_id' => $this->localeDe->id, + 'locale_id' => $this->localeDe->id, ], ]; @@ -92,20 +92,20 @@ class TriggerCest $I->assertNotNull($this->parentCategory); $this->categoryAttributes = [ - 'position' => 1, - 'status' => 1, - 'parent_id' => $this->parentCategory->id, + 'position' => 1, + 'status' => 1, + 'parent_id' => $this->parentCategory->id, $this->localeEn->code => [ - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), 'description' => $this->categoryName, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], $this->localeDe->code => [ - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), 'description' => $this->categoryName, - 'locale_id' => $this->localeDe->id, + 'locale_id' => $this->localeDe->id, ], ]; @@ -116,20 +116,20 @@ class TriggerCest $this->root2CategoryAttributes = [ - 'position' => 1, - 'status' => 1, - 'parent_id' => null, + 'position' => 1, + 'status' => 1, + 'parent_id' => null, $this->localeEn->code => [ - 'name' => $this->root2CategoryName, - 'slug' => strtolower($this->root2CategoryName), + 'name' => $this->root2CategoryName, + 'slug' => strtolower($this->root2CategoryName), 'description' => $this->root2CategoryName, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], $this->localeDe->code => [ - 'name' => $this->root2CategoryName, - 'slug' => strtolower($this->root2CategoryName), + 'name' => $this->root2CategoryName, + 'slug' => strtolower($this->root2CategoryName), 'description' => $this->root2CategoryName, - 'locale_id' => $this->localeDe->id, + 'locale_id' => $this->localeDe->id, ], ]; @@ -142,20 +142,20 @@ class TriggerCest $I->assertGreaterThan($rootCategory->_rgt, $this->root2Category->_lft); $this->childOfRoot2CategoryAttributes = [ - 'position' => 1, - 'status' => 1, - 'parent_id' => $this->root2Category->id, + 'position' => 1, + 'status' => 1, + 'parent_id' => $this->root2Category->id, $this->localeEn->code => [ - 'name' => $this->childOfRoot2CategoryName, - 'slug' => strtolower($this->childOfRoot2CategoryName), + 'name' => $this->childOfRoot2CategoryName, + 'slug' => strtolower($this->childOfRoot2CategoryName), 'description' => $this->childOfRoot2CategoryName, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], $this->localeDe->code => [ - 'name' => $this->childOfRoot2CategoryName, - 'slug' => strtolower($this->childOfRoot2CategoryName), + 'name' => $this->childOfRoot2CategoryName, + 'slug' => strtolower($this->childOfRoot2CategoryName), 'description' => $this->childOfRoot2CategoryName, - 'locale_id' => $this->localeDe->id, + 'locale_id' => $this->localeDe->id, ], ]; @@ -170,47 +170,47 @@ class TriggerCest { $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->parentCategory->id, - 'name' => $this->parentCategoryName, - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName), + 'name' => $this->parentCategoryName, + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->parentCategory->id, - 'name' => $this->parentCategoryName, - 'locale' => $this->localeDe->code, - 'url_path' => strtolower($this->parentCategoryName), + 'name' => $this->parentCategoryName, + 'locale' => $this->localeDe->code, + 'url_path' => strtolower($this->parentCategoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), + 'name' => $this->categoryName, + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'locale' => $this->localeDe->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), + 'name' => $this->categoryName, + 'locale' => $this->localeDe->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->root2Category->id, - 'name' => $this->root2CategoryName, - 'locale' => $this->localeEn->code, - 'url_path' => '', + 'name' => $this->root2CategoryName, + 'locale' => $this->localeEn->code, + 'url_path' => '', ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->childOfRoot2Category->id, - 'name' => $this->childOfRoot2CategoryName, - 'locale' => $this->localeDe->code, - 'url_path' => strtolower($this->childOfRoot2CategoryName), + 'name' => $this->childOfRoot2CategoryName, + 'locale' => $this->localeDe->code, + 'url_path' => strtolower($this->childOfRoot2CategoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->childOfRoot2Category->id, - 'name' => $this->childOfRoot2CategoryName, - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->childOfRoot2CategoryName), + 'name' => $this->childOfRoot2CategoryName, + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->childOfRoot2CategoryName), ]); } @@ -218,21 +218,21 @@ class TriggerCest { $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), - 'locale' => $this->localeDe->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), + 'locale' => $this->localeDe->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), ]); - $newCategoryName = $this->faker->word; + $newCategoryName = $this->faker->word; $this->categoryAttributes[$this->localeDe->code]['name'] = $newCategoryName; $this->categoryAttributes[$this->localeDe->code]['slug'] = strtolower($newCategoryName); $I->assertTrue($this->category->update($this->categoryAttributes)); @@ -240,18 +240,18 @@ class TriggerCest $I->dontSeeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $newCategoryName, - 'slug' => strtolower($this->categoryName), - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), + 'name' => $newCategoryName, + 'slug' => strtolower($this->categoryName), + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $newCategoryName, - 'slug' => strtolower($newCategoryName), - 'locale' => $this->localeDe->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($newCategoryName), + 'name' => $newCategoryName, + 'slug' => strtolower($newCategoryName), + 'locale' => $this->localeDe->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($newCategoryName), ]); } @@ -259,46 +259,46 @@ class TriggerCest { $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->parentCategory->id, - 'name' => $this->parentCategoryName, - 'slug' => strtolower($this->parentCategoryName), - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName), + 'name' => $this->parentCategoryName, + 'slug' => strtolower($this->parentCategoryName), + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName), ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . $this->categoryName, + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . $this->categoryName, ]); } public function testUpdateTriggersOnCategoriesTable(UnitTester $I) { $I->seeRecord(Category::class, [ - 'id' => $this->category->id, + 'id' => $this->category->id, 'parent_id' => $this->parentCategory->id, ]); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), - 'locale' => $this->localeEn->code, - 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), + 'locale' => $this->localeEn->code, + 'url_path' => strtolower($this->parentCategoryName) . '/' . strtolower($this->categoryName), ]); - $category2Name = $this->faker->word; + $category2Name = $this->faker->word; $category2Attributes = [ - 'position' => 1, - 'status' => 1, - 'parent_id' => $this->parentCategory->id, + 'position' => 1, + 'status' => 1, + 'parent_id' => $this->parentCategory->id, $this->localeEn->code => [ - 'name' => $category2Name, - 'slug' => strtolower($category2Name), + 'name' => $category2Name, + 'slug' => strtolower($category2Name), 'description' => $category2Name, - 'locale_id' => $this->localeEn->id, + 'locale_id' => $this->localeEn->id, ], ]; @@ -312,10 +312,10 @@ class TriggerCest $expectedUrlPath = strtolower($this->parentCategoryName) . '/' . strtolower($category2Name) . '/' . strtolower($this->categoryName); $I->seeRecord(CategoryTranslation::class, [ 'category_id' => $this->category->id, - 'name' => $this->categoryName, - 'slug' => strtolower($this->categoryName), - 'locale' => $this->localeEn->code, - 'url_path' => $expectedUrlPath, + 'name' => $this->categoryName, + 'slug' => strtolower($this->categoryName), + 'locale' => $this->localeEn->code, + 'url_path' => $expectedUrlPath, ]); } } diff --git a/tests/unit/CartRule/CartRuleCest.php b/tests/unit/CartRule/CartRuleCest.php index d38908e08..57a77d961 100644 --- a/tests/unit/CartRule/CartRuleCest.php +++ b/tests/unit/CartRule/CartRuleCest.php @@ -25,7 +25,6 @@ use Cart; class cartRuleWithCoupon { - public $cartRule; public $coupon; @@ -33,14 +32,12 @@ class cartRuleWithCoupon public function __construct(CartRule $cartRule, CartRuleCoupon $coupon) { $this->cartRule = $cartRule; - $this->coupon = $coupon; + $this->coupon = $coupon; } - } class expectedCartItem implements Arrayable { - public const ITEM_DISCOUNT_AMOUNT_PRECISION = 4; public const ITEM_TAX_AMOUNT_PRECISION = 4; @@ -77,65 +74,63 @@ class expectedCartItem implements Arrayable public function __construct(int $cartId, int $productId) { - $this->cart_id = $cartId; + $this->cart_id = $cartId; $this->product_id = $productId; } public function calcTotals(): void { - $this->total = $this->quantity * $this->price; + $this->total = $this->quantity * $this->price; $this->base_total = $this->quantity * $this->price; } public function calcTaxAmounts(): void { - $this->tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION); + $this->tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION); $this->base_tax_amount = round($this->quantity * $this->price * $this->tax_percent / 100, self::ITEM_TAX_AMOUNT_PRECISION); } public function calcFixedDiscountAmounts(float $discount, float $baseDiscount, string $code, int $cartRuleId): void { - $this->discount_amount = $this->quantity * $discount; - $this->base_discount_amount = $this->quantity * $baseDiscount; - $this->coupon_code = $code; - $this->applied_cart_rule_ids = (string) $cartRuleId; + $this->discount_amount = $this->quantity * $discount; + $this->base_discount_amount = $this->quantity * $baseDiscount; + $this->coupon_code = $code; + $this->applied_cart_rule_ids = (string)$cartRuleId; } public function calcPercentageDiscountAmounts(float $discount, string $code, int $cartRuleId): void { - $this->discount_percent = $discount; - $this->discount_amount = round(($this->total + $this->tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION); - $this->base_discount_amount = round(($this->base_total + $this->base_tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION); - $this->coupon_code = $code; - $this->applied_cart_rule_ids = (string) $cartRuleId; + $this->discount_percent = $discount; + $this->discount_amount = round(($this->total + $this->tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION); + $this->base_discount_amount = round(($this->base_total + $this->base_tax_amount) * $this->discount_percent / 100, self::ITEM_DISCOUNT_AMOUNT_PRECISION); + $this->coupon_code = $code; + $this->applied_cart_rule_ids = (string)$cartRuleId; } public function toArray(): array { return [ - 'cart_id' => $this->cart_id, - 'product_id' => $this->product_id, - 'quantity' => $this->quantity, - 'price' => $this->price, - 'base_price' => $this->base_price, - 'total' => $this->total, - 'base_total' => $this->base_total, - 'tax_percent' => $this->tax_percent, - 'tax_amount' => $this->tax_amount, - 'base_tax_amount' => $this->base_tax_amount, - 'coupon_code' => $this->coupon_code, - 'discount_percent' => $this->discount_percent, - 'discount_amount' => $this->discount_amount, - 'base_discount_amount' => $this->base_discount_amount, + 'cart_id' => $this->cart_id, + 'product_id' => $this->product_id, + 'quantity' => $this->quantity, + 'price' => $this->price, + 'base_price' => $this->base_price, + 'total' => $this->total, + 'base_total' => $this->base_total, + 'tax_percent' => $this->tax_percent, + 'tax_amount' => $this->tax_amount, + 'base_tax_amount' => $this->base_tax_amount, + 'coupon_code' => $this->coupon_code, + 'discount_percent' => $this->discount_percent, + 'discount_amount' => $this->discount_amount, + 'base_discount_amount' => $this->base_discount_amount, 'applied_cart_rule_ids' => $this->applied_cart_rule_ids, ]; } - } class expectedCart { - public const CART_TOTAL_PRECISION = 2; public $customer_id; @@ -168,39 +163,37 @@ class expectedCart public function __construct(int $cartId, int $customerId) { - $this->id = $cartId; + $this->id = $cartId; $this->customer_id = $customerId; } public function applyCoupon(int $cartRuleId, string $couponCode): void { - $this->coupon_code = $couponCode; - $this->applied_cart_rule_ids = (string) $cartRuleId; + $this->coupon_code = $couponCode; + $this->applied_cart_rule_ids = (string)$cartRuleId; } public function finalizeTotals(): void { - $this->sub_total = round($this->sub_total, self::CART_TOTAL_PRECISION); - $this->tax_total = round($this->tax_total, self::CART_TOTAL_PRECISION); + $this->sub_total = round($this->sub_total, self::CART_TOTAL_PRECISION); + $this->tax_total = round($this->tax_total, self::CART_TOTAL_PRECISION); $this->discount_amount = round($this->discount_amount, self::CART_TOTAL_PRECISION); - $this->grand_total = round($this->sub_total + $this->tax_total - $this->discount_amount, self::CART_TOTAL_PRECISION); + $this->grand_total = round($this->sub_total + $this->tax_total - $this->discount_amount, self::CART_TOTAL_PRECISION); - $this->base_sub_total = round($this->base_sub_total, self::CART_TOTAL_PRECISION); - $this->base_tax_total = round($this->base_tax_total, self::CART_TOTAL_PRECISION); + $this->base_sub_total = round($this->base_sub_total, self::CART_TOTAL_PRECISION); + $this->base_tax_total = round($this->base_tax_total, self::CART_TOTAL_PRECISION); $this->base_discount_amount = round($this->base_discount_amount, self::CART_TOTAL_PRECISION); - $this->base_grand_total = round($this->base_sub_total + $this->base_tax_total - $this->base_discount_amount, self::CART_TOTAL_PRECISION); + $this->base_grand_total = round($this->base_sub_total + $this->base_tax_total - $this->base_discount_amount, self::CART_TOTAL_PRECISION); } public function toArray(): array { - return (array) $this; + return (array)$this; } - } class expectedOrder implements Arrayable { - public $status; public $customer_email; @@ -247,63 +240,61 @@ class expectedOrder implements Arrayable public function __construct(expectedCart $expectedCart, Customer $customer, int $cartId) { - $this->status = 'pending'; - $this->customer_email = $customer->email; - $this->customer_first_name = $customer->first_name; - $this->customer_vat_id = $customer->vat_id; - $this->coupon_code = $expectedCart->coupon_code; - $this->total_item_count = $expectedCart->items_count; - $this->total_qty_ordered = $expectedCart->items_qty; - $this->grand_total = $expectedCart->grand_total; - $this->base_grand_total = $expectedCart->base_grand_total; - $this->sub_total = $expectedCart->sub_total; - $this->base_sub_total = $expectedCart->base_sub_total; - $this->discount_amount = $expectedCart->discount_amount; - $this->base_discount_amount = $expectedCart->base_discount_amount; - $this->tax_amount = $expectedCart->tax_total; - $this->base_tax_amount = $expectedCart->base_tax_total; - $this->customer_id = $customer->id; - $this->cart_id = $cartId; - $this->applied_cart_rule_ids = $expectedCart->applied_cart_rule_ids; - $this->shipping_method = null; - $this->shipping_amount = null; - $this->base_shipping_amount = null; + $this->status = 'pending'; + $this->customer_email = $customer->email; + $this->customer_first_name = $customer->first_name; + $this->customer_vat_id = $customer->vat_id; + $this->coupon_code = $expectedCart->coupon_code; + $this->total_item_count = $expectedCart->items_count; + $this->total_qty_ordered = $expectedCart->items_qty; + $this->grand_total = $expectedCart->grand_total; + $this->base_grand_total = $expectedCart->base_grand_total; + $this->sub_total = $expectedCart->sub_total; + $this->base_sub_total = $expectedCart->base_sub_total; + $this->discount_amount = $expectedCart->discount_amount; + $this->base_discount_amount = $expectedCart->base_discount_amount; + $this->tax_amount = $expectedCart->tax_total; + $this->base_tax_amount = $expectedCart->base_tax_total; + $this->customer_id = $customer->id; + $this->cart_id = $cartId; + $this->applied_cart_rule_ids = $expectedCart->applied_cart_rule_ids; + $this->shipping_method = null; + $this->shipping_amount = null; + $this->base_shipping_amount = null; $this->shipping_discount_amount = null; } public function toArray(): array { return [ - 'status' => $this->status, - 'customer_email' => $this->customer_email, - 'customer_first_name' => $this->customer_first_name, - 'customer_vat_id' => $this->customer_vat_id, - 'coupon_code' => $this->coupon_code, - 'total_item_count' => $this->total_item_count, - 'total_qty_ordered' => $this->total_qty_ordered, - 'grand_total' => $this->grand_total, - 'base_grand_total' => $this->base_grand_total, - 'sub_total' => $this->sub_total, - 'base_sub_total' => $this->base_sub_total, - 'discount_amount' => $this->discount_amount, - 'base_discount_amount' => $this->base_discount_amount, - 'tax_amount' => $this->tax_amount, - 'base_tax_amount' => $this->base_tax_amount, - 'customer_id' => $this->customer_id, - 'cart_id' => $this->cart_id, - 'applied_cart_rule_ids' => $this->applied_cart_rule_ids, - 'shipping_method' => $this->shipping_method, - 'shipping_amount' => $this->shipping_amount, - 'base_shipping_amount' => $this->base_shipping_amount, + 'status' => $this->status, + 'customer_email' => $this->customer_email, + 'customer_first_name' => $this->customer_first_name, + 'customer_vat_id' => $this->customer_vat_id, + 'coupon_code' => $this->coupon_code, + 'total_item_count' => $this->total_item_count, + 'total_qty_ordered' => $this->total_qty_ordered, + 'grand_total' => $this->grand_total, + 'base_grand_total' => $this->base_grand_total, + 'sub_total' => $this->sub_total, + 'base_sub_total' => $this->base_sub_total, + 'discount_amount' => $this->discount_amount, + 'base_discount_amount' => $this->base_discount_amount, + 'tax_amount' => $this->tax_amount, + 'base_tax_amount' => $this->base_tax_amount, + 'customer_id' => $this->customer_id, + 'cart_id' => $this->cart_id, + 'applied_cart_rule_ids' => $this->applied_cart_rule_ids, + 'shipping_method' => $this->shipping_method, + 'shipping_amount' => $this->shipping_amount, + 'base_shipping_amount' => $this->base_shipping_amount, 'shipping_discount_amount' => $this->shipping_discount_amount, ]; } - } class CartRuleCest { - private $products; private $sessionToken; @@ -371,51 +362,51 @@ class CartRuleCest // ], // ohne coupon [ - 'name' => 'PRODUCT_FREE no coupon', + 'name' => 'PRODUCT_FREE no coupon', 'productSequence' => [ self::PRODUCT_FREE, ], - 'withCoupon' => false, - 'checkOrder' => false, + 'withCoupon' => false, + 'checkOrder' => false, ], [ - 'name' => 'PRODUCT_NOT_FREE no coupon', + 'name' => 'PRODUCT_NOT_FREE no coupon', 'productSequence' => [ self::PRODUCT_NOT_FREE, ], - 'withCoupon' => false, - 'checkOrder' => false, + 'withCoupon' => false, + 'checkOrder' => false, ], // fixer Coupon für ein Produkt (Warenkorb wird nicht 0) [ - 'name' => 'PRODUCT_NOT_FREE fix coupon', + 'name' => 'PRODUCT_NOT_FREE fix coupon', 'productSequence' => [ self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_FIXED, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], [ - 'name' => 'check fix coupon on product with quantity=2', + 'name' => 'check fix coupon on product with quantity=2', 'productSequence' => [ self::PRODUCT_NOT_FREE, self::PRODUCT_NOT_FREE_REDUCED_TAX, self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_FIXED, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], // [ // 'name' => 'check fix coupon applied to two products', @@ -436,34 +427,34 @@ class CartRuleCest // ], // prozenturaler Coupon für ein Produkt (Warenkorb wird nicht 0) [ - 'name' => 'PRODUCT_NOT_FREE percentage coupon', + 'name' => 'PRODUCT_NOT_FREE percentage coupon', 'productSequence' => [ self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_PERCENTAGE, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], [ - 'name' => 'check percentage coupon on product with quantity=2', + 'name' => 'check percentage coupon on product with quantity=2', 'productSequence' => [ self::PRODUCT_NOT_FREE, self::PRODUCT_NOT_FREE_REDUCED_TAX, self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_PERCENTAGE, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], // [ // 'name' => 'check percentage coupon applied to two products', @@ -484,34 +475,34 @@ class CartRuleCest // ], // fixer Coupon für ein Produkt (Warenkorb wird 0) [ - 'name' => 'PRODUCT_NON_SUB_NOT_FREE fix coupon to zero', + 'name' => 'PRODUCT_NON_SUB_NOT_FREE fix coupon to zero', 'productSequence' => [ self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_FIXED_FULL, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], [ - 'name' => 'check fix coupon to zero on product with quantity=2', + 'name' => 'check fix coupon to zero on product with quantity=2', 'productSequence' => [ self::PRODUCT_NOT_FREE, self::PRODUCT_NOT_FREE_REDUCED_TAX, self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_FIXED_FULL, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], // [ // 'name' => 'check fix coupon to zero applied to two products', @@ -532,34 +523,34 @@ class CartRuleCest // ], // prozenturaler Coupon für ein Produkt (Warenkorb wird 0) [ - 'name' => 'PRODUCT_NOT_FREE percentage coupon to zero', + 'name' => 'PRODUCT_NOT_FREE percentage coupon to zero', 'productSequence' => [ self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_PERCENTAGE_FULL, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], [ - 'name' => 'check percentage coupon to zero on product with quantity=2', + 'name' => 'check percentage coupon to zero on product with quantity=2', 'productSequence' => [ self::PRODUCT_NOT_FREE, self::PRODUCT_NOT_FREE_REDUCED_TAX, self::PRODUCT_NOT_FREE, ], - 'withCoupon' => true, - 'couponScenario' => [ + 'withCoupon' => true, + 'couponScenario' => [ 'scenario' => self::COUPON_PERCENTAGE_FULL, 'products' => [ self::PRODUCT_NOT_FREE, ], ], - 'checkOrder' => false, + 'checkOrder' => false, ], // [ // 'name' => 'check percentage coupon to zero applied to two products', @@ -604,7 +595,7 @@ class CartRuleCest $this->sessionToken = $faker->uuid; session(['_token' => $this->sessionToken]); - $taxCategories = $this->generateTaxCategories($I); + $taxCategories = $this->generateTaxCategories($I); $this->products = $this->generateProducts($I, $scenario['productSequence'], $taxCategories); $cartRuleWithCoupon = null; @@ -614,9 +605,9 @@ class CartRuleCest foreach ($scenario['productSequence'] as $productIndex) { $data = [ - '_token' => session('_token'), + '_token' => session('_token'), 'product_id' => $this->products[$productIndex]->id, - 'quantity' => 1, + 'quantity' => 1, ]; cart()->addProduct($this->products[$productIndex]->id, $data); @@ -624,7 +615,7 @@ class CartRuleCest if ($scenario['withCoupon']) { $expectedCartCoupon = $cartRuleWithCoupon->coupon->code; - $I->comment('I try to use coupon code '.$expectedCartCoupon); + $I->comment('I try to use coupon code ' . $expectedCartCoupon); cart() ->setCouponCode($expectedCartCoupon) ->collectTotals(); @@ -655,43 +646,43 @@ class CartRuleCest $customerAddress = $I->have(CustomerAddress::class, [ 'first_name' => $customer->first_name, - 'last_name' => $customer->last_name, - 'country' => 'DE', + 'last_name' => $customer->last_name, + 'country' => 'DE', ]); $billing = [ - 'address1' => $customerAddress->address1, + 'address1' => $customerAddress->address1, 'use_for_shipping' => true, - 'first_name' => $customerAddress->first_name, - 'last_name' => $customerAddress->last_name, - 'email' => $customer->email, - 'company_name' => $customerAddress->company_name, - 'city' => $customerAddress->city, - 'postcode' => $customerAddress->postcode, - 'country' => $customerAddress->country, - 'state' => $customerAddress->state, - 'phone' => $customerAddress->phone, + 'first_name' => $customerAddress->first_name, + 'last_name' => $customerAddress->last_name, + 'email' => $customer->email, + 'company_name' => $customerAddress->company_name, + 'city' => $customerAddress->city, + 'postcode' => $customerAddress->postcode, + 'country' => $customerAddress->country, + 'state' => $customerAddress->state, + 'phone' => $customerAddress->phone, ]; $shipping = [ - 'address1' => '', + 'address1' => '', 'first_name' => $customerAddress->first_name, - 'last_name' => $customerAddress->last_name, - 'email' => $customer->email, + 'last_name' => $customerAddress->last_name, + 'email' => $customer->email, ]; cart()->saveCustomerAddress([ - 'billing' => $billing, + 'billing' => $billing, 'shipping' => $shipping, ]); cart()->saveShippingMethod('free_free'); cart()->savePaymentMethod(['method' => 'mollie_creditcard']); $I->assertFalse(cart()->hasError()); - $orderItemRepository = new OrderItemRepository(app()); - $downloadableLinkRepository = new ProductDownloadableLinkRepository(app()); + $orderItemRepository = new OrderItemRepository(app()); + $downloadableLinkRepository = new ProductDownloadableLinkRepository(app()); $downloadableLinkPurchasedRepository = new DownloadableLinkPurchasedRepository($downloadableLinkRepository, app()); - $orderRepository = new OrderRepository($orderItemRepository, $downloadableLinkPurchasedRepository, app()); + $orderRepository = new OrderRepository($orderItemRepository, $downloadableLinkPurchasedRepository, app()); $orderRepository->create(cart()->prepareDataForOrder()); $expectedOrder = new expectedOrder($expectedCart, $customer, $cart->id); @@ -720,76 +711,76 @@ class CartRuleCest session(['_token' => $this->sessionToken]); $tax = $I->have(TaxRate::class, [ - 'country' => 'DE', + 'country' => 'DE', 'tax_rate' => 19.0, ]); $taxCategorie = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ - 'tax_rate_id' => $tax->id, + 'tax_rate_id' => $tax->id, 'tax_category_id' => $taxCategorie->id, ]); $productConfig = [ 'attributeValues' => [ - 'price' => 23.92, + 'price' => 23.92, 'tax_category_id' => $taxCategorie->id, ], ]; - $product = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $productConfig); + $product = $I->haveProduct(Laravel5Helper::SIMPLE_PRODUCT, $productConfig); $ruleConfig = [ - 'action_type' => self::ACTION_TYPE_PERCENTAGE, + 'action_type' => self::ACTION_TYPE_PERCENTAGE, 'discount_amount' => 100, - 'conditions' => [ + 'conditions' => [ [ - 'attribute' => 'product|sku', - 'value' => $product->sku, - 'operator' => '==', + 'attribute' => 'product|sku', + 'value' => $product->sku, + 'operator' => '==', 'attribute_type' => 'text', ], ], ]; - $cartRule = $I->have(CartRule::class, $ruleConfig); + $cartRule = $I->have(CartRule::class, $ruleConfig); DB::table('cart_rule_channels') ->insert([ 'cart_rule_id' => $cartRule->id, - 'channel_id' => core()->getCurrentChannel()->id, + 'channel_id' => core()->getCurrentChannel()->id, ]); $guestCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'guest']); DB::table('cart_rule_customer_groups') ->insert([ - 'cart_rule_id' => $cartRule->id, + 'cart_rule_id' => $cartRule->id, 'customer_group_id' => $guestCustomerGroup['id'], ]); $generalCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'general']); DB::table('cart_rule_customer_groups') ->insert([ - 'cart_rule_id' => $cartRule->id, + 'cart_rule_id' => $cartRule->id, 'customer_group_id' => $generalCustomerGroup['id'], ]); $coupon = $I->have(CartRuleCoupon::class, [ - 'code' => 'AWESOME', + 'code' => 'AWESOME', 'cart_rule_id' => $cartRule->id, ]); $data = [ - '_token' => session('_token'), + '_token' => session('_token'), 'product_id' => $product->id, - 'quantity' => 1, + 'quantity' => 1, ]; cart()->addProduct($product->id, $data); cart() ->setCouponCode('AWESOME') ->collectTotals(); - $cart = cart()->getCart(); + $cart = cart()->getCart(); $cartItem = $cart->items() ->first(); @@ -834,8 +825,8 @@ class CartRuleCest break; case self::PRODUCT_NOT_FREE: - $cartItem->price = self::PRODUCT_PRICE; - $cartItem->base_price = self::PRODUCT_PRICE; + $cartItem->price = self::PRODUCT_PRICE; + $cartItem->base_price = self::PRODUCT_PRICE; $cartItem->tax_percent = self::TAX_RATE; $cartItem->calcTotals(); @@ -843,8 +834,8 @@ class CartRuleCest break; case self::PRODUCT_NOT_FREE_REDUCED_TAX: - $cartItem->price = self::REDUCED_PRODUCT_PRICE; - $cartItem->base_price = self::REDUCED_PRODUCT_PRICE; + $cartItem->price = self::REDUCED_PRODUCT_PRICE; + $cartItem->base_price = self::REDUCED_PRODUCT_PRICE; $cartItem->tax_percent = self::REDUCED_TAX_RATE; $cartItem->calcTotals(); @@ -900,7 +891,7 @@ class CartRuleCest } if ($scenario['withCoupon'] && $scenario['couponScenario']['scenario'] === self::COUPON_FIXED_CART) { - $totals = $this->calcTotals($cartItems); + $totals = $this->calcTotals($cartItems); $cartItems = $this->splitDiscountToItems($cartItems, $cartRuleWithCoupon, $totals); } @@ -910,14 +901,14 @@ class CartRuleCest private function calcTotals(array $cartItems): array { $result = [ - 'subTotal' => 0.0, + 'subTotal' => 0.0, 'baseSubTotal' => 0.0, ]; foreach ($cartItems as $expectedCartItem) { - $result['subTotal'] += $expectedCartItem->total; + $result['subTotal'] += $expectedCartItem->total; $result['baseSubTotal'] += $expectedCartItem->base_total; } - $result['subTotal'] = round($result['subTotal'], expectedCart::CART_TOTAL_PRECISION); + $result['subTotal'] = round($result['subTotal'], expectedCart::CART_TOTAL_PRECISION); $result['baseSubTotal'] = round($result['baseSubTotal'], expectedCart::CART_TOTAL_PRECISION); return $result; @@ -928,26 +919,26 @@ class CartRuleCest cartRuleWithCoupon $cartRuleWithCoupon, array $totals ): array { - $discountAmount = self::DISCOUNT_AMOUNT_CART; + $discountAmount = self::DISCOUNT_AMOUNT_CART; $baseDiscountAmount = self::DISCOUNT_AMOUNT_CART; // split coupon amount to cart items $length = count($cartItems) - 1; for ($i = 0; $i < $length; $i++) { $cartItems[$i]->discount_amount = round(self::DISCOUNT_AMOUNT_CART * $cartItems[$i]->total / $totals['subTotal'], expectedCartItem::ITEM_DISCOUNT_AMOUNT_PRECISION); - $discountAmount -= $cartItems[$i]->discount_amount; + $discountAmount -= $cartItems[$i]->discount_amount; $cartItems[$i]->base_discount_amount = round(self::DISCOUNT_AMOUNT_CART * $cartItems[$i]->base_total / $totals['baseSubTotal'], expectedCartItem::ITEM_DISCOUNT_AMOUNT_PRECISION); - $baseDiscountAmount -= $cartItems[$i]->discount_amount; + $baseDiscountAmount -= $cartItems[$i]->discount_amount; - $cartItems[$i]->coupon_code = $cartRuleWithCoupon->coupon->code; - $cartItems[$i]->applied_cart_rule_ids = (string) $cartRuleWithCoupon->cartRule->id; + $cartItems[$i]->coupon_code = $cartRuleWithCoupon->coupon->code; + $cartItems[$i]->applied_cart_rule_ids = (string)$cartRuleWithCoupon->cartRule->id; } - $cartItems[$length]->discount_amount = $discountAmount; + $cartItems[$length]->discount_amount = $discountAmount; $cartItems[$length]->base_discount_amount = $baseDiscountAmount; - $cartItems[$length]->coupon_code = $cartRuleWithCoupon->coupon->code; - $cartItems[$length]->applied_cart_rule_ids = (string) $cartRuleWithCoupon->cartRule->id; + $cartItems[$length]->coupon_code = $cartRuleWithCoupon->coupon->code; + $cartItems[$length]->applied_cart_rule_ids = (string)$cartRuleWithCoupon->cartRule->id; return $cartItems; } @@ -996,12 +987,12 @@ class CartRuleCest $cart->items_count++; $cart->items_qty += $cartItem->quantity; - $cart->sub_total += $cartItem->total; - $cart->tax_total += $cartItem->tax_amount; + $cart->sub_total += $cartItem->total; + $cart->tax_total += $cartItem->tax_amount; $cart->discount_amount += $cartItem->discount_amount; - $cart->base_sub_total += $cartItem->base_total; - $cart->base_tax_total += $cartItem->base_tax_amount; + $cart->base_sub_total += $cartItem->base_total; + $cart->base_tax_total += $cartItem->base_tax_amount; $cart->base_discount_amount += $cartItem->base_discount_amount; } @@ -1017,18 +1008,18 @@ class CartRuleCest */ private function generateTaxCategories(UnitTester $I): array { - $result = []; + $result = []; $country = strtoupper(Config::get('app.default_country')) ?? 'DE'; foreach ($this->getTaxRateSpecifications() as $taxSpec => $taxRate) { $tax = $I->have(TaxRate::class, [ - 'country' => $country, + 'country' => $country, 'tax_rate' => $taxRate, ]); $taxCategorie = $I->have(TaxCategory::class); $I->have(TaxMap::class, [ - 'tax_rate_id' => $tax->id, + 'tax_rate_id' => $tax->id, 'tax_category_id' => $taxCategorie->id, ]); @@ -1048,11 +1039,11 @@ class CartRuleCest */ private function generateProducts(UnitTester $I, array $scenario, array $taxCategories): array { - $products = []; + $products = []; $productSpecs = $this->getProductSpecifications(); foreach ($scenario as $item) { - $productConfig = $this->makeProductConfig($productSpecs[$item], $taxCategories); + $productConfig = $this->makeProductConfig($productSpecs[$item], $taxCategories); $products[$item] = $I->haveProduct($productSpecs[$item]['productType'], $productConfig); } @@ -1070,26 +1061,26 @@ class CartRuleCest $faker = Factory::create(); $couponSpecifications = $this->getCouponSpecifications(); - $ruleConfig = $this->makeRuleConfig($couponSpecifications[$couponConfig['scenario']], $this->products, $couponConfig['products']); - $cartRule = $I->have(CartRule::class, $ruleConfig); + $ruleConfig = $this->makeRuleConfig($couponSpecifications[$couponConfig['scenario']], $this->products, $couponConfig['products']); + $cartRule = $I->have(CartRule::class, $ruleConfig); DB::table('cart_rule_channels') ->insert([ 'cart_rule_id' => $cartRule->id, - 'channel_id' => core()->getCurrentChannel()->id, + 'channel_id' => core()->getCurrentChannel()->id, ]); $guestCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'guest']); DB::table('cart_rule_customer_groups') ->insert([ - 'cart_rule_id' => $cartRule->id, + 'cart_rule_id' => $cartRule->id, 'customer_group_id' => $guestCustomerGroup['id'], ]); $generalCustomerGroup = $I->grabRecord('customer_groups', ['code' => 'general']); DB::table('cart_rule_customer_groups') ->insert([ - 'cart_rule_id' => $cartRule->id, + 'cart_rule_id' => $cartRule->id, 'customer_group_id' => $generalCustomerGroup['id'], ]); @@ -1112,8 +1103,8 @@ class CartRuleCest 'productInventory' => [ 'qty' => 100, ], - 'attributeValues' => [ - 'price' => 0.0, + 'attributeValues' => [ + 'price' => 0.0, 'tax_category_id' => $taxCategories[self::TAX_CATEGORY], ], ]; @@ -1146,17 +1137,17 @@ class CartRuleCest { foreach ($couponableProducts as $item) { $conditions[] = [ - 'value' => $products[$item]->sku, - 'operator' => '==', - 'attribute' => 'product|sku', + 'value' => $products[$item]->sku, + 'operator' => '==', + 'attribute' => 'product|sku', 'attribute_type' => 'text', ]; } $result = [ - 'action_type' => $ruleSpec['actionType'], + 'action_type' => $ruleSpec['actionType'], 'discount_amount' => $ruleSpec['discountAmount'], - 'conditions' => $conditions ?? null, + 'conditions' => $conditions ?? null, ]; return $result; @@ -1170,21 +1161,21 @@ class CartRuleCest return [ [ 'productScenario' => self::PRODUCT_FREE, - 'productType' => Laravel5Helper::SIMPLE_PRODUCT, - 'freeOfCharge' => true, - 'reducedTax' => false, + 'productType' => Laravel5Helper::SIMPLE_PRODUCT, + 'freeOfCharge' => true, + 'reducedTax' => false, ], [ 'productScenario' => self::PRODUCT_NOT_FREE, - 'productType' => Laravel5Helper::SIMPLE_PRODUCT, - 'freeOfCharge' => false, - 'reducedTax' => false, + 'productType' => Laravel5Helper::SIMPLE_PRODUCT, + 'freeOfCharge' => false, + 'reducedTax' => false, ], [ 'productScenario' => self::PRODUCT_NOT_FREE_REDUCED_TAX, - 'productType' => Laravel5Helper::SIMPLE_PRODUCT, - 'freeOfCharge' => false, - 'reducedTax' => true, + 'productType' => Laravel5Helper::SIMPLE_PRODUCT, + 'freeOfCharge' => false, + 'reducedTax' => true, ], ]; } @@ -1197,27 +1188,27 @@ class CartRuleCest return [ [ 'couponScenario' => self::COUPON_FIXED, - 'actionType' => self::ACTION_TYPE_FIXED, + 'actionType' => self::ACTION_TYPE_FIXED, 'discountAmount' => self::DISCOUNT_AMOUNT_FIX, ], [ 'couponScenario' => self::COUPON_FIXED_FULL, - 'actionType' => self::ACTION_TYPE_FIXED, + 'actionType' => self::ACTION_TYPE_FIXED, 'discountAmount' => self::DISCOUNT_AMOUNT_FIX_FULL, ], [ 'couponScenario' => self::COUPON_PERCENTAGE, - 'actionType' => self::ACTION_TYPE_PERCENTAGE, + 'actionType' => self::ACTION_TYPE_PERCENTAGE, 'discountAmount' => self::DISCOUNT_AMOUNT_PERCENT, ], [ 'couponScenario' => self::COUPON_PERCENTAGE_FULL, - 'actionType' => self::ACTION_TYPE_PERCENTAGE, + 'actionType' => self::ACTION_TYPE_PERCENTAGE, 'discountAmount' => 100.0, ], [ 'couponScenario' => self::COUPON_FIXED_CART, - 'actionType' => self::ACTION_TYPE_CART_FIXED, + 'actionType' => self::ACTION_TYPE_CART_FIXED, 'discountAmount' => self::DISCOUNT_AMOUNT_CART, ], ]; @@ -1229,7 +1220,7 @@ class CartRuleCest private function getTaxRateSpecifications(): array { return [ - self::TAX_CATEGORY => self::TAX_RATE, + self::TAX_CATEGORY => self::TAX_RATE, self::TAX_REDUCED_CATEGORY => self::REDUCED_TAX_RATE, ]; } @@ -1251,6 +1242,4 @@ class CartRuleCest return null; } - - } \ No newline at end of file