- working on test cases.
- update codeception driver for laravel.
This commit is contained in:
parent
029b77df23
commit
1320e493d2
|
|
@ -42,7 +42,8 @@
|
|||
"codeception/codeception": "^4.1",
|
||||
"codeception/module-asserts": "^1.1",
|
||||
"codeception/module-filesystem": "^1.0",
|
||||
"codeception/module-laravel5": "^1.0",
|
||||
"codeception/module-laravel": "^2.0",
|
||||
"codeception/module-laravel5": "^1.1",
|
||||
"codeception/module-webdriver": "^1.0",
|
||||
"filp/whoops": "^2.0",
|
||||
"mockery/mockery": "^1.3.1",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -25,7 +25,7 @@ class AttributeOptionFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'admin_name' => $this->faker->word,
|
||||
'sort_order' => $this->faker->randomDigit,
|
||||
'sort_order' => $this->faker->randomDigit(),
|
||||
'attribute_id' => Attribute::factory(['swatch_type' => 'text']),
|
||||
'swatch_value' => null,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -4,65 +4,88 @@ namespace Webkul\Attribute\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Product\Models\ProductProxy;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Webkul\Attribute\Database\Factories\AttributeFamilyFactory;
|
||||
use Webkul\Attribute\Contracts\AttributeFamily as AttributeFamilyContract;
|
||||
|
||||
class AttributeFamily extends Model implements AttributeFamilyContract
|
||||
{
|
||||
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = ['code', 'name'];
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'name',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all of the attributes for the attribute groups.
|
||||
* Get all the attributes for the attribute groups.
|
||||
*/
|
||||
public function custom_attributes()
|
||||
{
|
||||
return (AttributeProxy::modelClass())::join('attribute_group_mappings', 'attributes.id', '=', 'attribute_group_mappings.attribute_id')
|
||||
->join('attribute_groups', 'attribute_group_mappings.attribute_group_id', '=', 'attribute_groups.id')
|
||||
->join('attribute_families', 'attribute_groups.attribute_family_id', '=', 'attribute_families.id')
|
||||
->where('attribute_families.id', $this->id)
|
||||
->select('attributes.*');
|
||||
->join('attribute_groups', 'attribute_group_mappings.attribute_group_id', '=', 'attribute_groups.id')
|
||||
->join('attribute_families', 'attribute_groups.attribute_family_id', '=', 'attribute_families.id')
|
||||
->where('attribute_families.id', $this->id)
|
||||
->select('attributes.*');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all of the comparable attributes which belongs to attribute family.
|
||||
* Get all the comparable attributes which belongs to attribute family.
|
||||
*/
|
||||
public function getComparableAttributesBelongsToFamily()
|
||||
{
|
||||
return (AttributeProxy::modelClass())::join('attribute_group_mappings', 'attribute_group_mappings.attribute_id', '=', 'attributes.id')
|
||||
->select('attributes.*')->where('attributes.is_comparable', 1)->distinct()->get();
|
||||
->select('attributes.*')
|
||||
->where('attributes.is_comparable', 1)
|
||||
->distinct()
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the attributes for the attribute groups.
|
||||
* Get all the attributes for the attribute groups.
|
||||
*/
|
||||
public function getCustomAttributesAttribute()
|
||||
{
|
||||
return $this->custom_attributes()->get();
|
||||
return $this->custom_attributes()
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the attribute groups.
|
||||
* Get all the attribute groups.
|
||||
*/
|
||||
public function attribute_groups()
|
||||
public function attribute_groups(): HasMany
|
||||
{
|
||||
return $this->hasMany(AttributeGroupProxy::modelClass())->orderBy('position');
|
||||
return $this->hasMany(AttributeGroupProxy::modelClass())
|
||||
->orderBy('position');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the attributes for the attribute groups.
|
||||
* Get all the attributes for the attribute groups.
|
||||
*/
|
||||
public function getConfigurableAttributesAttribute()
|
||||
{
|
||||
return $this->custom_attributes()->where('attributes.is_configurable', 1)->where('attributes.type', 'select')->get();
|
||||
return $this->custom_attributes()
|
||||
->where('attributes.is_configurable', 1)
|
||||
->where('attributes.type', 'select')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the products.
|
||||
* Get all the products.
|
||||
*/
|
||||
public function products()
|
||||
public function products(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProductProxy::modelClass());
|
||||
}
|
||||
|
||||
protected static function newFactory(): AttributeFamilyFactory
|
||||
{
|
||||
return AttributeFamilyFactory::new();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,10 +4,17 @@ namespace Webkul\Attribute\Models;
|
|||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Core\Eloquent\TranslatableModel;
|
||||
use Illuminate\Testing\Fluent\Concerns\Has;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Webkul\Attribute\Database\Factories\AttributeOptionFactory;
|
||||
use Webkul\Attribute\Contracts\AttributeOption as AttributeOptionContract;
|
||||
|
||||
class AttributeOption extends TranslatableModel implements AttributeOptionContract
|
||||
{
|
||||
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public $translatedAttributes = ['label'];
|
||||
|
|
@ -22,7 +29,7 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
|
|||
/**
|
||||
* Get the attribute that owns the attribute option.
|
||||
*/
|
||||
public function attribute()
|
||||
public function attribute(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AttributeProxy::modelClass());
|
||||
}
|
||||
|
|
@ -35,7 +42,7 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
|
|||
if ($this->swatch_value && $this->attribute->swatch_type == 'image') {
|
||||
return url('cache/small/'.$this->swatch_value);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -46,4 +53,10 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra
|
|||
{
|
||||
return $this->swatch_value_url();
|
||||
}
|
||||
|
||||
protected static function newFactory(): AttributeOptionFactory
|
||||
{
|
||||
return AttributeOptionFactory::new();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
namespace Webkul\CartRule\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Core\Database\Factories\CartRuleFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Webkul\CartRule\Database\Factories\CartRuleFactory;
|
||||
use Webkul\CartRule\Contracts\CartRule as CartRuleContract;
|
||||
use Webkul\Core\Models\ChannelProxy;
|
||||
use Webkul\Customer\Models\CustomerGroupProxy;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class CategoryFactory extends Factory
|
|||
{
|
||||
return [
|
||||
'status' => 1,
|
||||
'position' => $this->faker->randomDigit,
|
||||
'position' => $this->faker->randomDigit(),
|
||||
'parent_id' => 1,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Kalnoy\Nestedset\NodeTrait;
|
|||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Webkul\Category\Database\Factories\CategoryFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Webkul\Category\Contracts\Category as CategoryContract;
|
||||
use Webkul\Attribute\Models\AttributeProxy;
|
||||
|
|
@ -69,7 +70,7 @@ class Category extends TranslatableModel implements CategoryContract
|
|||
/**
|
||||
* The filterable attributes that belong to the category.
|
||||
*/
|
||||
public function filterableAttributes()
|
||||
public function filterableAttributes(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(AttributeProxy::modelClass(), 'category_filterable_attributes')
|
||||
->with([
|
||||
|
|
@ -82,28 +83,29 @@ class Category extends TranslatableModel implements CategoryContract
|
|||
/**
|
||||
* Getting the root category of a category
|
||||
*
|
||||
* @return Category
|
||||
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object
|
||||
*/
|
||||
public function getRootCategory(): Category
|
||||
public function getRootCategory()
|
||||
{
|
||||
return Category::where([
|
||||
[
|
||||
'parent_id',
|
||||
'=',
|
||||
null,
|
||||
],
|
||||
[
|
||||
'_lft',
|
||||
'<=',
|
||||
$this->_lft,
|
||||
],
|
||||
[
|
||||
'_rgt',
|
||||
'>=',
|
||||
$this->_rgt,
|
||||
],
|
||||
])
|
||||
->first();
|
||||
return self::query()
|
||||
->where([
|
||||
[
|
||||
'parent_id',
|
||||
'=',
|
||||
null,
|
||||
],
|
||||
[
|
||||
'_lft',
|
||||
'<=',
|
||||
$this->_lft,
|
||||
],
|
||||
[
|
||||
'_rgt',
|
||||
'>=',
|
||||
$this->_rgt,
|
||||
],
|
||||
])
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,7 +158,7 @@ class Category extends TranslatableModel implements CategoryContract
|
|||
/**
|
||||
* The products that belong to the category.
|
||||
*/
|
||||
public function products()
|
||||
public function products(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(ProductProxy::modelClass(), 'product_categories');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use Webkul\Category\Contracts\CategoryTranslation as CategoryTranslationContract
|
|||
*/
|
||||
class CategoryTranslation extends Model implements CategoryTranslationContract
|
||||
{
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
|
|
@ -25,4 +26,5 @@ class CategoryTranslation extends Model implements CategoryTranslationContract
|
|||
'meta_keywords',
|
||||
'locale_id',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -32,10 +32,8 @@ class CartFactory extends Factory
|
|||
->select('id')
|
||||
->first();
|
||||
|
||||
$customer = Customer::factory()
|
||||
->create();
|
||||
$cartAddress = CartAddress::factory()
|
||||
->create();
|
||||
$customer = Customer::factory()
|
||||
->create();
|
||||
|
||||
return [
|
||||
'is_guest' => 0,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\CartRule\Database\Factories;
|
||||
namespace Webkul\Core\Database\Factories;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Webkul\CartRule\Models\CartRule;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Webkul\Core\Helpers;
|
|||
|
||||
use StdClass;
|
||||
use Faker\Factory;
|
||||
use Codeception\Module\Laravel5;
|
||||
use Codeception\Module\Laravel;
|
||||
use Webkul\Checkout\Models\Cart;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
@ -30,18 +30,22 @@ use Webkul\Product\Models\ProductDownloadableLinkTranslation;
|
|||
*
|
||||
* @package Webkul\Core\Helpers
|
||||
*/
|
||||
class Laravel5Helper extends Laravel5
|
||||
class Laravel5Helper extends Laravel
|
||||
{
|
||||
|
||||
public const SIMPLE_PRODUCT = 1;
|
||||
|
||||
public const VIRTUAL_PRODUCT = 2;
|
||||
|
||||
public const DOWNLOADABLE_PRODUCT = 3;
|
||||
|
||||
public const BOOKING_EVENT_PRODUCT = 4;
|
||||
|
||||
/**
|
||||
* Returns the field name of the given attribute in which a value should be saved inside
|
||||
* the 'product_attribute_values' table. Depends on the type.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $type
|
||||
*
|
||||
* @return string|null
|
||||
* @part ORM
|
||||
|
|
@ -85,10 +89,10 @@ class Laravel5Helper extends Laravel5
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +133,7 @@ class Laravel5Helper extends Laravel5
|
|||
|
||||
// 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]);
|
||||
|
||||
|
|
@ -146,7 +150,7 @@ class Laravel5Helper extends Laravel5
|
|||
/**
|
||||
* Set all session with the given key and value in the array.
|
||||
*
|
||||
* @param array $keyValue
|
||||
* @param array $keyValue
|
||||
*/
|
||||
public function setSession(array $keyValue): void
|
||||
{
|
||||
|
|
@ -169,9 +173,9 @@ class Laravel5Helper extends Laravel5
|
|||
* By default, the product will be generated as saleable, this means it has a price,
|
||||
* weight, is active and has a positive inventory stock, if necessary.
|
||||
*
|
||||
* @param int $productType see constants in this class for usage
|
||||
* @param array $configs
|
||||
* @param array $productStates
|
||||
* @param int $productType see constants in this class for usage
|
||||
* @param array $configs
|
||||
* @param array $productStates
|
||||
*
|
||||
* @return \Webkul\Product\Models\Product
|
||||
* @part ORM
|
||||
|
|
@ -208,7 +212,7 @@ class Laravel5Helper extends Laravel5
|
|||
private function haveSimpleProduct(array $configs = [], array $productStates = []): Product
|
||||
{
|
||||
$I = $this;
|
||||
if (! in_array('simple', $productStates)) {
|
||||
if (!in_array('simple', $productStates)) {
|
||||
$productStates = array_merge($productStates, ['simple']);
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +228,7 @@ class Laravel5Helper extends Laravel5
|
|||
private function haveVirtualProduct(array $configs = [], array $productStates = []): Product
|
||||
{
|
||||
$I = $this;
|
||||
if (! in_array('virtual', $productStates)) {
|
||||
if (!in_array('virtual', $productStates)) {
|
||||
$productStates = array_merge($productStates, ['virtual']);
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +244,7 @@ class Laravel5Helper extends Laravel5
|
|||
private function haveDownloadableProduct(array $configs = [], array $productStates = []): Product
|
||||
{
|
||||
$I = $this;
|
||||
if (! in_array('downloadable', $productStates)) {
|
||||
if (!in_array('downloadable', $productStates)) {
|
||||
$productStates = array_merge($productStates, ['downloadable']);
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +260,7 @@ class Laravel5Helper extends Laravel5
|
|||
private function haveBookingEventProduct(array $configs = [], array $productStates = []): Product
|
||||
{
|
||||
$I = $this;
|
||||
if (! in_array('booking', $productStates)) {
|
||||
if (!in_array('booking', $productStates)) {
|
||||
$productStates = array_merge($productStates, ['booking']);
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +275,13 @@ class Laravel5Helper extends Laravel5
|
|||
|
||||
private function createProduct(array $attributes = [], array $states = []): Product
|
||||
{
|
||||
return factory(Product::class)->states($states)->create($attributes);
|
||||
return Product::factory()
|
||||
->state(function () use ($states) {
|
||||
return [
|
||||
'type' => $states[0],
|
||||
];
|
||||
})
|
||||
->create($attributes);
|
||||
}
|
||||
|
||||
private function createInventory(int $productId, array $inventoryConfig = []): void
|
||||
|
|
@ -285,7 +295,7 @@ class Laravel5Helper extends Laravel5
|
|||
|
||||
private function createDownloadableLink(int $productId): void
|
||||
{
|
||||
$I = $this;
|
||||
$I = $this;
|
||||
$link = $I->have(ProductDownloadableLink::class, [
|
||||
'product_id' => $productId,
|
||||
]);
|
||||
|
|
@ -297,7 +307,7 @@ class Laravel5Helper extends Laravel5
|
|||
|
||||
private function createBookingEventProduct(int $productId): void
|
||||
{
|
||||
$I = $this;
|
||||
$I = $this;
|
||||
$bookingProduct = $I->have(BookingProduct::class, [
|
||||
'product_id' => $productId,
|
||||
]);
|
||||
|
|
@ -314,17 +324,16 @@ class Laravel5Helper extends Laravel5
|
|||
$faker = Factory::create();
|
||||
|
||||
$brand = Attribute::query()
|
||||
->where(['code' => 'brand'])
|
||||
->firstOrFail(); // usually 25
|
||||
->where(['code' => 'brand'])
|
||||
->firstOrFail(); // usually 25
|
||||
|
||||
if (! AttributeOption::query()
|
||||
->where(['attribute_id' => $brand->id])
|
||||
->exists()) {
|
||||
if (!AttributeOption::query()
|
||||
->where(['attribute_id' => $brand->id])
|
||||
->exists()) {
|
||||
AttributeOption::create([
|
||||
'admin_name' => 'Webkul Demo Brand (c) 2020',
|
||||
'attribute_id' => $brand->id,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -345,17 +354,19 @@ class Laravel5Helper extends Laravel5
|
|||
'special_price_to' => null,
|
||||
'special_price' => null,
|
||||
'price' => $faker->randomFloat(2, 1, 1000),
|
||||
'weight' => '1.00', // necessary for shipping
|
||||
'brand' => AttributeOption::query()->firstWhere('attribute_id', $brand->id)->id,
|
||||
'weight' => '1.00',
|
||||
// necessary for shipping
|
||||
'brand' => AttributeOption::query()
|
||||
->firstWhere('attribute_id', $brand->id)->id,
|
||||
];
|
||||
|
||||
$attributeValues = array_merge($defaultAttributeValues, $attributeValues);
|
||||
|
||||
/** @var array $possibleAttributeValues list of the possible attributes a product can have */
|
||||
$possibleAttributeValues = DB::table('attributes')
|
||||
->select('id', 'code', 'type')
|
||||
->get()
|
||||
->toArray();
|
||||
->select('id', 'code', 'type')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
foreach ($possibleAttributeValues as $attributeSet) {
|
||||
$data = [
|
||||
|
|
@ -374,14 +385,14 @@ class Laravel5Helper extends Laravel5
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $attributeCode
|
||||
* @param array $data
|
||||
* @param string $attributeCode
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function appendAttributeDependencies(string $attributeCode, array $data): array
|
||||
{
|
||||
$locale = core()->getCurrentLocale()->code;
|
||||
$locale = core()->getCurrentLocale()->code;
|
||||
$channel = core()->getCurrentChannelCode();
|
||||
|
||||
$attributeSetDependencies = [
|
||||
|
|
@ -389,7 +400,7 @@ class Laravel5Helper extends Laravel5
|
|||
'locale',
|
||||
'channel',
|
||||
],
|
||||
'tax_category_id' => [
|
||||
'tax_category_id' => [
|
||||
'channel',
|
||||
],
|
||||
'short_description' => [
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ProductAttributeValueFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'product_id' => Product::factory(),
|
||||
//'product_id' => Product::factory(),
|
||||
'locale' => 'en',
|
||||
'channel' => 'default',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class OrderItemFactory extends Factory
|
|||
->first();
|
||||
} else {
|
||||
$product = Product::factory()
|
||||
->simple()
|
||||
->create();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue