- Fixing coding style.

- Fixing typo.
This commit is contained in:
Abdullah Al-Faqeir 2021-10-06 15:26:08 +03:00
parent 7b612ecc67
commit 8e3c43bd19
57 changed files with 641 additions and 677 deletions

View File

@ -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 [];
}
}

View File

@ -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,
];
}
}

View File

@ -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,
];
}
}

View File

@ -40,7 +40,7 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
return url('cache/small/' . $this->swatch_value);
}
return;
return null;
}
/**

View File

@ -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');
}
}

View File

@ -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');
}
}

View File

@ -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,
];
}

View File

@ -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',
];
}

View File

@ -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,
];
}

View File

@ -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,
];
}
}

View File

@ -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,
];

View File

@ -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');
}
}

View File

@ -145,7 +145,7 @@ class Core
}
/**
* Returns currenct channel models.
* Returns current channel models.
*
* @return \Webkul\Core\Contracts\Channel
*/

View File

@ -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(),
];
}
}

View File

@ -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,
];
}
}

View File

@ -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),
];
}
}

View File

@ -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,
];
}

View File

@ -35,8 +35,8 @@ class LocaleFactory extends Factory
->exists());
return [
'code' => $languageCode,
'name' => $this->faker->country,
'code' => $languageCode,
'name' => $this->faker->country,
'direction' => 'ltr',
];
}

View File

@ -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,
];
}
}

View File

@ -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;
}
}

View File

@ -1,9 +1,7 @@
<?php
namespace Webkul\Core\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -12,7 +10,6 @@ use Webkul\Core\Contracts\Address as AddressContract;
/**
* Class Address
*
* @package Webkul\Core\Models
*
* @property string $address_type
@ -41,7 +38,6 @@ use Webkul\Core\Contracts\Address as AddressContract;
*/
abstract class Address extends Model implements AddressContract
{
protected $table = 'addresses';
protected $guarded = [
@ -82,7 +78,7 @@ abstract class Address extends Model implements AddressContract
*/
public function getNameAttribute(): string
{
return $this->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);
}
}

View File

@ -6,7 +6,7 @@ use Konekt\Concord\BaseModuleServiceProvider;
class CoreModuleServiceProvider extends BaseModuleServiceProvider
{
public function boot()
public function boot(): void
{
if ($this->areMigrationsEnabled()) {
$this->registerMigrations();

View File

@ -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']);
});
}
}

View File

@ -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,
];
}
}

View File

@ -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),
];
}

View File

@ -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),
];
}
}

View File

@ -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());
}

View File

@ -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');
}
}

View File

@ -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,
];
}
}

View File

@ -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
{
}
}

View File

@ -24,8 +24,8 @@ class ProductAttributeValueFactory extends Factory
{
return [
//'product_id' => Product::factory(),
'locale' => 'en',
'channel' => 'default',
'locale' => 'en',
'channel' => 'default',
];
}
}

View File

@ -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,

View File

@ -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(),
];
}

View File

@ -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,
];
}

View File

@ -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(),
];
}

View File

@ -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(),
];
}

View File

@ -1,13 +1,13 @@
<?php
namespace Webkul\Category\Database\Seeders;
namespace Webkul\Product\Database\Seeders;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
class ProductTableSeeder extends Seeder
{
public function run()
public function run(): void
{
//dd('running');
}

View File

@ -17,21 +17,21 @@ class GenerateProduct
{
/**
* Product Repository instance
*
*
* @var \Webkul\Product\Repositories\ProductRepository
*/
protected $productRepository;
/**
* AttributeFamily Repository instance
*
*
* @var \Webkul\Product\Repositories\AttributeFamilyRepository
*/
protected $attributeFamilyRepository;
/**
* Product Attribute Types
*
*
* @var array
*/
protected $types;
@ -70,7 +70,7 @@ class GenerateProduct
/**
* This brand option needs to be available so that the generated product
* can be linked to the order_brands table after checkout.
*
*
* @return void
*/
public function generateDemoBrand()

View File

@ -421,7 +421,7 @@ class Product extends Model implements ProductContract
return;
}
$locale = core()->checkRequestedLocaleCodeInRequestedChannel();
$locale = core()->checkRequestedLocaleCodeInRequestedChannel();
$channel = core()->getRequestedChannelCode();
if (array_key_exists($this->id, self::$loadedAttributeValues)

View File

@ -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',
];
/**

View File

@ -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);
});
}
}

View File

@ -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'],
];
}

View File

@ -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(),
];
}
}

View File

@ -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(),
];
}

View File

@ -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',
];
}

View File

@ -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,
];
}

View File

@ -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(),
];
}

View File

@ -32,8 +32,8 @@ class Invoice extends Model implements InvoiceContract
* @var array
*/
protected $statusLabel = [
'pending' => 'Pending',
'paid' => 'Paid',
'pending' => 'Pending',
'paid' => 'Paid',
'refunded' => 'Refunded',
];

View File

@ -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);

View File

@ -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);

View File

@ -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');
}
}

View File

@ -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),
];
}

View File

@ -25,7 +25,7 @@ class TaxMapFactory extends Factory
{
return [
'tax_category_id' => TaxCategory::factory(),
'tax_rate_id' => TaxRate::factory(),
'tax_rate_id' => TaxRate::factory(),
];
}
}

View File

@ -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),
];
}
}

View File

@ -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();

View File

@ -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,
]);
}
}

View File

@ -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;
}
}