Company test added

This commit is contained in:
EnesSacid-Buker
2022-12-16 14:09:06 +03:00
parent 4cb869d451
commit 7bef3d1569
2 changed files with 130 additions and 43 deletions

View File

@ -3,9 +3,7 @@
namespace Database\Factories;
use App\Abstracts\Factory;
use App\Models\Auth\User;
use App\Models\Common\Company as Model;
use Illuminate\Support\Facades\Artisan;
class Company extends Factory
{
@ -24,8 +22,11 @@ class Company extends Factory
public function definition()
{
return [
'name' => $this->faker->company,
'email' => $this->faker->freeEmail,
'currency' => $this->faker->randomElement(array_keys(\Akaunting\Money\Currency::getCurrencies())),
'country' => $this->faker->randomElement(array_keys(trans('countries'))),
'enabled' => $this->faker->boolean ? 1 : 0,
'created_from' => 'core::factory',
];
}
@ -52,44 +53,4 @@ class Company extends Factory
'enabled' => 0,
]);
}
/**
* Configure the model factory.
*
* @return $this
*/
public function configure()
{
return $this->afterCreating(function (Model $company) {
$company->makeCurrent();
app()->setLocale('en-GB');
// Company seeds
Artisan::call('company:seed', [
'company' => $company->id
]);
$user = User::first();
$user->companies()->attach($company->id);
// User seeds
Artisan::call('user:seed', [
'user' => $user->id,
'company' => $company->id,
]);
setting()->set([
'company.name' => $this->faker->text(15),
'company.address' => 'New Street 1254',
'company.city' => 'London',
'company.country' => $this->faker->countryCode,
'default.currency' => 'USD',
'default.locale' => 'en-GB',
]);
setting()->save();
});
}
}