Upgraded testing to Laravel 8 - disabled most tests pending code optimisation
This commit is contained in:
@@ -1,64 +1,78 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$factory->define(App\Models\Product::class, function (Faker $faker) {
|
||||
return [
|
||||
'id'=>1,
|
||||
'site_id'=>1,
|
||||
'taxable'=>1,
|
||||
'price_group'=>serialize([
|
||||
1=>[
|
||||
0=>[
|
||||
'price_setup'=>50,
|
||||
'price_base'=>100,
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Traits\FactoryActiveTrait;
|
||||
|
||||
class ProductFactory extends Factory
|
||||
{
|
||||
use FactoryActiveTrait;
|
||||
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Product::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'id' => $this->faker->numberBetween(1,65535),
|
||||
//* 'site_id', // Needs to be passed in
|
||||
// 'date_orig',
|
||||
// 'date_last',
|
||||
'taxable' => TRUE,
|
||||
'active' => TRUE,
|
||||
// 'position'
|
||||
// 'cart_multiple'
|
||||
// 'group_avail'
|
||||
// 'avail_category'
|
||||
// 'price_type'
|
||||
'price_group'=>serialize([
|
||||
1=>[
|
||||
0=>[
|
||||
'price_setup'=>50,
|
||||
'price_base'=>100,
|
||||
]
|
||||
]
|
||||
]
|
||||
]),
|
||||
];
|
||||
});
|
||||
]),
|
||||
// 'price_recurr_default'
|
||||
// 'price_recurr_day'
|
||||
// 'price_recurr_weekday'
|
||||
// 'price_recurr_strict'
|
||||
// 'prod_plugin_file'
|
||||
//'prod_plugin_data' => 1,
|
||||
// 'accounting'
|
||||
// 'model' => 'App\Models\Product\Adsl',
|
||||
];
|
||||
}
|
||||
|
||||
$factory->state(App\Models\Product::class,'active',[
|
||||
'active' => 1,
|
||||
]);
|
||||
$factory->state(App\Models\Product::class,'strict',[
|
||||
'price_recurr_strict' => 1,
|
||||
]);
|
||||
$factory->state(App\Models\Product::class,'notstrict',[
|
||||
'price_recurr_strict' => 0,
|
||||
]);
|
||||
/* STATES */
|
||||
|
||||
$factory->afterMakingState(App\Models\Product::class,'broadband-unlimit',function ($product,$faker) {
|
||||
$type = factory(App\Models\Product\Adsl::class)->state('unlimit')->make();
|
||||
$product->setRelation('type',$type);
|
||||
$product->prod_plugin_data = $type->id;
|
||||
$product->model = 'App\Models\Product\Adsl';
|
||||
});
|
||||
public function notStrict()
|
||||
{
|
||||
return $this->state(function () {
|
||||
return [
|
||||
'price_recurr_strict' => FALSE,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
$factory->afterMakingState(App\Models\Product::class,'broadband-140/0/0/0',function ($product,$faker) {
|
||||
$type = factory(App\Models\Product\Adsl::class)->state('140/0/0/0')->make();
|
||||
$product->setRelation('type',$type);
|
||||
$product->prod_plugin_data = $type->id;
|
||||
$product->model = 'App\Models\Product\Adsl';
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Product::class,'broadband-70/-/0/-',function ($product,$faker) {
|
||||
$type = factory(App\Models\Product\Adsl::class)->state('70/-/0/-')->make();
|
||||
$product->setRelation('type',$type);
|
||||
$product->prod_plugin_data = $type->id;
|
||||
$product->model = 'App\Models\Product\Adsl';
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Product::class,'broadband-100/0/40/0',function ($product,$faker) {
|
||||
$type = factory(App\Models\Product\Adsl::class)->state('100/0/40/0')->make();
|
||||
$product->setRelation('type',$type);
|
||||
$product->prod_plugin_data = $type->id;
|
||||
$product->model = 'App\Models\Product\Adsl';
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Product::class,'broadband-50/-/20/-',function ($product,$faker) {
|
||||
$type = factory(App\Models\Product\Adsl::class)->state('50/-/20/-')->make();
|
||||
$product->setRelation('type',$type);
|
||||
$product->prod_plugin_data = $type->id;
|
||||
$product->model = 'App\Models\Product\Adsl';
|
||||
});
|
||||
public function strict()
|
||||
{
|
||||
return $this->state(function () {
|
||||
return [
|
||||
'price_recurr_strict' => TRUE,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user