add some factories into webkul core package to enhance testing potential
This commit is contained in:
parent
217412a563
commit
e76c1794b9
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Checkout\Models\CartAddress;
|
||||
|
||||
$factory->define(CartAddress::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
return [
|
||||
'first_name' => $faker->firstName(),
|
||||
'last_name' => $faker->lastName,
|
||||
'email' => $faker->email,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'address_type' => 'billing',
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\Checkout\Models\Cart;
|
||||
use Webkul\Checkout\Models\CartAddress;
|
||||
|
||||
$factory->define(Cart::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
$lastOrder = DB::table('orders')
|
||||
->orderBy('id', 'desc')
|
||||
->select('id')
|
||||
->first();
|
||||
|
||||
$customer = factory(Customer::class)->create();
|
||||
$cartAddress = factory(CartAddress::class)->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',
|
||||
'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,
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Checkout\Models\CartItem;
|
||||
|
||||
$factory->define(CartItem::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
return [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Checkout\Models\CartPayment;
|
||||
|
||||
$factory->define(CartPayment::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
return [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Category\Models\Category;
|
||||
|
||||
$factory->define(Category::class, function (Faker $faker, array $attributes) {
|
||||
|
||||
return [
|
||||
'status' => 1,
|
||||
'position' => $faker->randomDigit,
|
||||
'parent_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Category::class, 'inactive', [
|
||||
'status' => 0,
|
||||
]);
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
|
||||
$factory->define(Customer::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
$gender = array_rand(['male', 'female', 'other']);
|
||||
$password = $faker->password;
|
||||
return [
|
||||
'first_name' => $faker->firstName($gender),
|
||||
'last_name' => $faker->lastName,
|
||||
'gender' => ucfirst($gender),
|
||||
'email' => $faker->email,
|
||||
'status' => 1,
|
||||
'password' => Hash::make($password),
|
||||
'customer_group_id' => 2,
|
||||
'is_verified' => 1,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'notes' => json_encode(array('plain_password' => $password)),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Customer::class, 'male', [
|
||||
'gender' => 'Male',
|
||||
]);
|
||||
|
||||
$factory->state(Customer::class, 'female', [
|
||||
'gender' => 'Female',
|
||||
]);
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Inventory\Models\InventorySource;
|
||||
|
||||
$factory->define(InventorySource::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
$code = $faker->unique()->word;
|
||||
return [
|
||||
'code' => $faker->unique()->word,
|
||||
'name' => $code,
|
||||
'description' => $faker->sentence,
|
||||
'contact_name' => $faker->name,
|
||||
'contact_email' => $faker->safeEmail,
|
||||
'contact_number' => $faker->phoneNumber,
|
||||
'country' => $faker->countryCode,
|
||||
'state' => $faker->state,
|
||||
'city' => $faker->city,
|
||||
'street' => $faker->streetAddress,
|
||||
'postcode' => $faker->postcode,
|
||||
'priority' => 0,
|
||||
'status' => 1,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Sales\Models\Invoice;
|
||||
use Webkul\Sales\Models\InvoiceItem;
|
||||
use Webkul\Sales\Models\OrderItem;
|
||||
|
||||
$factory->define(InvoiceItem::class, function (Faker $faker, array $attributes) {
|
||||
|
||||
$basePrice = $faker->randomFloat(2);
|
||||
$quantity = $faker->randomNumber();
|
||||
|
||||
if (! $attributes['order_item_id']) {
|
||||
$attributes['order_item_id'] = function () {
|
||||
return factory(OrderItem::class)->create()->id;
|
||||
};
|
||||
}
|
||||
|
||||
$orderItem = OrderItem::find($attributes['order_item_id']);
|
||||
|
||||
return [
|
||||
'name' => $faker->word,
|
||||
'sku' => $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' => function () {
|
||||
return factory(Invoice::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Core\Models\Channel;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\Sales\Models\Order;
|
||||
use Webkul\Product\Models\Product;
|
||||
|
||||
$factory->define(Order::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
$lastOrder = DB::table('orders')
|
||||
->orderBy('id', 'desc')
|
||||
->select('id')
|
||||
->first();
|
||||
|
||||
$customer = factory(Customer::class)->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,
|
||||
'base_grand_total_invoiced' => 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,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'cart_id' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Order::class, 'pending', [
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
$factory->state(Order::class, 'completed', [
|
||||
'status' => 'completed',
|
||||
]);
|
||||
|
||||
$factory->state(Order::class, 'closed', [
|
||||
'status' => 'closed',
|
||||
]);
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Sales\Models\Order;
|
||||
use Webkul\Sales\Models\OrderItem;
|
||||
|
||||
$factory->define(OrderItem::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
$product = factory(Product::class, 'simple')->create();
|
||||
|
||||
return [
|
||||
'sku' => $product->sku,
|
||||
'type' => $product->type,
|
||||
'name' => $product->name,
|
||||
'price' => $product->price,
|
||||
'base_price' => $product->price,
|
||||
'total' => $product->price,
|
||||
'base_total' => $product->price,
|
||||
'product_id' => $product->id,
|
||||
'qty_ordered' => 1,
|
||||
'qty_shipped' => 0,
|
||||
'qty_invoiced' => 0,
|
||||
'qty_canceled' => 0,
|
||||
'qty_refunded' => 0,
|
||||
'order_id' => function () {
|
||||
return factory(Order::class)->create()->id;
|
||||
},
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Sales\Models\OrderPayment;
|
||||
|
||||
$factory->define(OrderPayment::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
|
||||
return [
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Product\Models\ProductAttributeValue;
|
||||
use Webkul\Attribute\Models\AttributeOption;
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'sku', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'text_value' => $faker->uuid,
|
||||
'attribute_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'name', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'locale' => 'en', //$faker->languageCode,
|
||||
'channel' => 'default',
|
||||
'text_value' => $faker->words(2, true),
|
||||
'attribute_id' => 2,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'url_key', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'text_value' => $faker->unique()->slug,
|
||||
'attribute_id' => 3,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'tax_category_id', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'channel' => 'default',
|
||||
'integer_value' => null, // ToDo
|
||||
'attribute_id' => 4,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'new', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'boolean_value' => 1,
|
||||
'attribute_id' => 5,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'featured', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'boolean_value' => 1,
|
||||
'attribute_id' => 6,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'visible_individually', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'boolean_value' => 1,
|
||||
'attribute_id' => 7,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'status', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'boolean_value' => 1,
|
||||
'attribute_id' => 8,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'short_description', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'locale' => 'en', //$faker->languageCode,
|
||||
'channel' => 'default',
|
||||
'text_value' => $faker->sentence,
|
||||
'attribute_id' => 9,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'description', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'locale' => 'en', //$faker->languageCode,
|
||||
'channel' => 'default',
|
||||
'text_value' => $faker->sentences(3, true),
|
||||
'attribute_id' => 10,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'price', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'float_value' => $faker->randomFloat(4, 0, 1000),
|
||||
'attribute_id' => 11,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'cost', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'channel' => 'default',
|
||||
'float_value' => $faker->randomFloat(4, 0, 10),
|
||||
'attribute_id' => 12,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'special_price', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'float_value' => $faker->randomFloat(4, 0, 100),
|
||||
'attribute_id' => 13,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'special_price_from', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'channel' => 'default',
|
||||
'date_value' => $faker->dateTimeBetween('-5 days', 'now', 'Europe/Berlin'),
|
||||
'attribute_id' => 14,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'special_price_to', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'channel' => 'default',
|
||||
'date_value' => $faker->dateTimeBetween('now', '+ 5 days', 'Europe/Berlin'),
|
||||
'attribute_id' => 15,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'meta_title', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'locale' => 'en', //$faker->languageCode,
|
||||
'channel' => 'default',
|
||||
'text_value' => $faker->words(2, true),
|
||||
'attribute_id' => 16,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'meta_keywords', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'locale' => 'en', //$faker->languageCode,
|
||||
'channel' => 'default',
|
||||
'text_value' => $faker->words(5, true),
|
||||
'attribute_id' => 17,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'meta_description', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'locale' => 'en', //$faker->languageCode,
|
||||
'channel' => 'default',
|
||||
'text_value' => $faker->sentence,
|
||||
'attribute_id' => 18,
|
||||
];
|
||||
});
|
||||
$factory->defineAs(ProductAttributeValue::class, 'width', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'integer_value' => $faker->numberBetween(1, 50),
|
||||
'attribute_id' => 19,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'height', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'integer_value' => $faker->numberBetween(1, 50),
|
||||
'attribute_id' => 20,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'depth', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'integer_value' => $faker->numberBetween(1, 50),
|
||||
'attribute_id' => 21,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'weight', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'integer_value' => $faker->numberBetween(1, 50),
|
||||
'attribute_id' => 22,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'color', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'integer_value' => $faker->numberBetween(1, 5),
|
||||
'attribute_id' => 23,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'size', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'integer_value' => $faker->numberBetween(1, 5),
|
||||
'attribute_id' => 24,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(ProductAttributeValue::class, 'brand', function (Faker $faker) {
|
||||
return [
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'attribute_id' => 25,
|
||||
'integer_value' => function () {
|
||||
return factory(AttributeOption::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\ProductDownloadableLink;
|
||||
use Webkul\Product\Models\ProductDownloadableLinkTranslation;
|
||||
|
||||
$factory->define(ProductDownloadableLink::class, function (Faker $faker) {
|
||||
$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' => $faker->randomNumber(1),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(ProductDownloadableLinkTranslation::class, function (Faker $faker) {
|
||||
return [
|
||||
'locale' => 'en',
|
||||
'title' => $faker->word,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Product\Models\Product;
|
||||
|
||||
$factory->define(Product::class, function (Faker $faker) {
|
||||
$now = date("Y-m-d H:i:s");
|
||||
return [
|
||||
'sku' => $faker->uuid,
|
||||
'type' => 'virtual',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
'attribute_family_id' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Product::class, 'simple', [
|
||||
'type' => 'simple',
|
||||
]);
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Webkul\Inventory\Models\InventorySource;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Product\Models\ProductInventory;
|
||||
|
||||
$factory->define(ProductInventory::class, function (Faker $faker) {
|
||||
return [
|
||||
'qty' => $faker->numberBetween(1, 20),
|
||||
'product_id' => function () {
|
||||
return factory(Product::class)->create()->id;
|
||||
},
|
||||
'inventory_source_id' => function () {
|
||||
return factory(InventorySource::class)->create()->id;
|
||||
},
|
||||
//'vendor_id' => 0, // this is default in DB schema
|
||||
];
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue