Upgraded testing to Laravel 8 - disabled most tests pending code optimisation
This commit is contained in:
@@ -1,15 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$factory->define(App\Models\Account::class, function (Faker $faker) {
|
||||
return [
|
||||
'id'=>1,
|
||||
];
|
||||
});
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
$factory->afterMaking(App\Models\Account::class, function ($service,$faker) {
|
||||
$country = factory(App\Models\Country::class)->make();
|
||||
$service->setRelation('country',$country);
|
||||
$service->country_id = $country->id;
|
||||
});
|
||||
use App\Models\{Account,Country,Currency,Language};
|
||||
|
||||
class AccountFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Account::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
// Create Dependencies - should be loaded by seeding.
|
||||
$co = Country::findOrFail(61);
|
||||
$lo = Language::findOrFail(1);
|
||||
$cyo = Currency::findOrFail(6);
|
||||
|
||||
return [
|
||||
'id' => $this->faker->numberBetween(2048,65535),
|
||||
// 'date_orig',
|
||||
// 'date_last',
|
||||
//* 'site_id', // Needs to be passed in
|
||||
// 'date_expire',
|
||||
'language_id' => $lo->id,
|
||||
'country_id' => $co->id,
|
||||
// 'rtm_id',
|
||||
'currency_id' => $cyo->id,
|
||||
// 'username',
|
||||
// 'password',
|
||||
'active' => TRUE,
|
||||
// 'first_name',
|
||||
// 'last_name',
|
||||
// 'title',
|
||||
// 'email',
|
||||
// 'company',
|
||||
// 'address1',
|
||||
// 'address2',
|
||||
// 'city',
|
||||
// 'state',
|
||||
// 'zip',
|
||||
// 'email_type',
|
||||
// 'invoice_delivery',
|
||||
// 'mail_type',
|
||||
// 'remember_token',
|
||||
// 'user_id',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Country::class, function (Faker $faker) {
|
||||
return [
|
||||
'id'=>1222,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterMaking(App\Models\Country::class, function ($service,$faker) {
|
||||
$taxes = factory(App\Models\Tax::class,1)->make();
|
||||
$service->setRelation('taxes',$taxes);
|
||||
});
|
35
database/factories/GroupFactory.php
Normal file
35
database/factories/GroupFactory.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Group;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class GroupFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Group::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'id' => 1,
|
||||
// 'site_id' // Needs to be passed in
|
||||
// 'date_start',
|
||||
// 'date_expire',
|
||||
// 'parent_id',
|
||||
'active' => TRUE,
|
||||
// 'pricing',
|
||||
// 'name',
|
||||
];
|
||||
}
|
||||
}
|
@@ -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,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -1,111 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
namespace Database\Factories;
|
||||
|
||||
$factory->define(App\Models\Service::class, function (Faker $faker) {
|
||||
return [
|
||||
'active'=>1,
|
||||
];
|
||||
});
|
||||
use App\Models\Service;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
$factory->afterMaking(App\Models\Service::class, function ($service,$faker) {
|
||||
$product = factory(App\Models\Product::class)->make();
|
||||
$service->setRelation('product',$product);
|
||||
$service->product_id = $product->id;
|
||||
class ServiceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Service::class;
|
||||
|
||||
$account = factory(App\Models\Account::class)->make();
|
||||
$service->setRelation('account',$account);
|
||||
$service->account_id = $account->id;
|
||||
});
|
||||
public function configure()
|
||||
{
|
||||
return $this->afterMaking(function (Service $service) {
|
||||
/*
|
||||
$product = factory(App\Models\Product::class)->make();
|
||||
$service->setRelation('product',$product);
|
||||
$service->product_id = $product->id;
|
||||
|
||||
// Weekly
|
||||
$factory->afterMakingState(App\Models\Service::class,'week',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('week')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 0;
|
||||
});
|
||||
$account = factory(App\Models\Account::class)->make();
|
||||
$service->setRelation('account',$account);
|
||||
$service->account_id = $account->id;
|
||||
*/
|
||||
|
||||
$factory->afterMakingState(App\Models\Service::class,'week-mid',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('week-mid')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 0;
|
||||
});
|
||||
})->afterCreating(function (Service $service) {
|
||||
//
|
||||
});
|
||||
}
|
||||
|
||||
// Monthly
|
||||
$factory->afterMakingState(App\Models\Service::class,'month',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('month')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 1;
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Service::class,'month-mid',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('month-mid')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 1;
|
||||
});
|
||||
|
||||
// Quarterly
|
||||
$factory->afterMakingState(App\Models\Service::class,'quarter',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('quarter')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 2;
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Service::class,'quarter-mid',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('quarter-mid')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 2;
|
||||
});
|
||||
|
||||
// Half Yearly
|
||||
$factory->afterMakingState(App\Models\Service::class,'half',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('half')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 3;
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Service::class,'half-mid',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('half-mid')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 3;
|
||||
});
|
||||
|
||||
// Yearly
|
||||
$factory->afterMakingState(App\Models\Service::class,'year',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('year')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 4;
|
||||
});
|
||||
|
||||
$factory->afterMakingState(App\Models\Service::class,'year-mid',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('year-mid')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 4;
|
||||
});
|
||||
|
||||
// 2 Yearly
|
||||
$factory->afterMakingState(App\Models\Service::class,'2year',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('2year')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 5;
|
||||
});
|
||||
|
||||
// 3 Yearly
|
||||
$factory->afterMakingState(App\Models\Service::class,'3year',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('3year')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 6;
|
||||
});
|
||||
|
||||
// Last Month
|
||||
$factory->afterMakingState(App\Models\Service::class,'next-invoice',function ($service,$faker) {
|
||||
$invoice_items = factory(App\Models\InvoiceItem::class,1)->state('next-invoice')->make();
|
||||
$service->setRelation('invoice_items',$invoice_items);
|
||||
$service->recur_schedule = 1;
|
||||
});
|
||||
|
||||
// New Connect
|
||||
$factory->afterMakingState(App\Models\Service::class,'new-connect',function ($service,$faker) {
|
||||
$service->recur_schedule = 1;
|
||||
$service->date_next_invoice = \Carbon\Carbon::now()->subMonth()->startOfMonth()->addDays(\Carbon\Carbon::now()->subMonth()->daysInMonth/2);
|
||||
});
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'id' => $this->faker->numberBetween(1,65535),
|
||||
// 'date_orig',
|
||||
// 'date_last',
|
||||
//* 'site_id', // Needs to be passed in
|
||||
//* 'account_id'
|
||||
// 'account_billing_id'
|
||||
// 'product_id' =
|
||||
'active' => TRUE,
|
||||
'suspend_billing' => FALSE,
|
||||
'external_billing' => FALSE,
|
||||
'price' => 100,
|
||||
'price_group' => 1,
|
||||
// 'price_override',
|
||||
// 'taxable',
|
||||
// 'queue',
|
||||
'date_last_invoice' => Carbon::createFromFormat('Y-m-d','2021-01-01'),
|
||||
// 'date_next_invoice',
|
||||
// 'recur_schedule',
|
||||
// 'prod_attr',
|
||||
// 'date_start',
|
||||
// 'date_end',
|
||||
// 'orderedby_id',
|
||||
// 'order_status',
|
||||
// 'order_info',
|
||||
'model' => 'App\Models\Service\Adsl',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
46
database/factories/SiteFactory.php
Normal file
46
database/factories/SiteFactory.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use App\Models\{Country,Currency,Language,Site};
|
||||
|
||||
class SiteFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Site::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
// Create Dependencies - should be loaded by seeding.
|
||||
$co = Country::findOrFail(61);
|
||||
$lo = Language::findOrFail(1);
|
||||
$cyo = Currency::findOrFail(6);
|
||||
|
||||
return [
|
||||
'id' => $this->faker->numberBetween(255,65535),
|
||||
// date_orig
|
||||
'active' => TRUE,
|
||||
'country_id' => $co->id,
|
||||
'language_id' => $lo->id,
|
||||
'currency_id' => $cyo->id,
|
||||
// 'url'', // Needs to be passed in
|
||||
// login_expire,
|
||||
// time_format,
|
||||
// date_format,
|
||||
// decimal_place,
|
||||
// module_config,
|
||||
// site_details,
|
||||
// admin_date,
|
||||
];
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@ class CurrencyTableSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
$o = new Currency;
|
||||
$o->id = 610;
|
||||
$o->id = 6;
|
||||
$o->name = 'Australian Dollars';
|
||||
$o->symbol = '$';
|
||||
$o->iso_code = 'AUD';
|
||||
|
@@ -15,12 +15,40 @@ class SiteTableSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Test Sites 254 & 255
|
||||
$o = new Site;
|
||||
$o->id = 1;
|
||||
$o->id = 254;
|
||||
// $o->date_orig
|
||||
$o->active = TRUE;
|
||||
$o->country_id = 61;
|
||||
$o->language_id = 1;
|
||||
$o->currency_id = 610;
|
||||
$o->url = 'test';
|
||||
$o->currency_id = 6;
|
||||
$o->url = 'test1';
|
||||
// $o->login_expire;
|
||||
// $o->time_format;
|
||||
// $o->date_format;
|
||||
// $o->decimal_place;
|
||||
// $o->module_config;
|
||||
// $o->site_details;
|
||||
// $o->admin_date;
|
||||
$o->save();
|
||||
|
||||
// Test Sites 254 & 255
|
||||
$o = new Site;
|
||||
$o->id = 255;
|
||||
// $o->date_orig
|
||||
$o->active = TRUE;
|
||||
$o->country_id = 61;
|
||||
$o->language_id = 1;
|
||||
$o->currency_id = 6;
|
||||
$o->url = 'test2';
|
||||
// $o->login_expire;
|
||||
// $o->time_format;
|
||||
// $o->date_format;
|
||||
// $o->decimal_place;
|
||||
// $o->module_config;
|
||||
// $o->site_details;
|
||||
// $o->admin_date;
|
||||
$o->save();
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@ class UserTableSeeder extends Seeder
|
||||
$o->site_id = 1;
|
||||
$o->language_id = 1;
|
||||
$o->country_id = 61;
|
||||
$o->currency_id = 610;
|
||||
$o->currency_id = 6;
|
||||
$o->active = 1;
|
||||
$o->firstname = 'Wholesaler';
|
||||
$o->lastname = 'User';
|
||||
@@ -32,7 +32,7 @@ class UserTableSeeder extends Seeder
|
||||
$o->site_id = 1;
|
||||
$o->language_id = 1;
|
||||
$o->country_id = 61;
|
||||
$o->currency_id = 610;
|
||||
$o->currency_id = 6;
|
||||
$o->active = 1;
|
||||
$o->firstname = 'reseller1-0';
|
||||
$o->lastname = 'User';
|
||||
@@ -44,7 +44,7 @@ class UserTableSeeder extends Seeder
|
||||
$o->site_id = 1;
|
||||
$o->language_id = 1;
|
||||
$o->country_id = 61;
|
||||
$o->currency_id = 610;
|
||||
$o->currency_id = 6;
|
||||
$o->active = 1;
|
||||
$o->firstname = 'reseller2-0';
|
||||
$o->lastname = 'User';
|
||||
@@ -56,7 +56,7 @@ class UserTableSeeder extends Seeder
|
||||
$o->site_id = 1;
|
||||
$o->language_id = 1;
|
||||
$o->country_id = 61;
|
||||
$o->currency_id = 610;
|
||||
$o->currency_id = 6;
|
||||
$o->active = 1;
|
||||
$o->firstname = 'reseller2-1';
|
||||
$o->lastname = 'User';
|
||||
@@ -68,7 +68,7 @@ class UserTableSeeder extends Seeder
|
||||
$o->site_id = 1;
|
||||
$o->language_id = 1;
|
||||
$o->country_id = 61;
|
||||
$o->currency_id = 610;
|
||||
$o->currency_id = 6;
|
||||
$o->active = 1;
|
||||
$o->firstname = 'user1-0-1';
|
||||
$o->lastname = 'User';
|
||||
@@ -80,7 +80,7 @@ class UserTableSeeder extends Seeder
|
||||
$o->site_id = 1;
|
||||
$o->language_id = 1;
|
||||
$o->country_id = 61;
|
||||
$o->currency_id = 610;
|
||||
$o->currency_id = 6;
|
||||
$o->active = 1;
|
||||
$o->firstname = 'user2-1-1';
|
||||
$o->lastname = 'User';
|
||||
|
Reference in New Issue
Block a user