Added user related factories
parent
4ff44d141c
commit
ec355d40f5
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Engelsystem\Models\User;
|
||||
|
||||
use Engelsystem\Models\User\Contact;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ContactFactory extends Factory
|
||||
{
|
||||
/** @var string */
|
||||
protected $model = Contact::class;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'dect' => $this->faker->optional()->numberBetween(1000, 9999),
|
||||
'email' => $this->faker->unique()->optional()->safeEmail(),
|
||||
'mobile' => $this->faker->optional(.2)->phoneNumber(),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Engelsystem\Models\User;
|
||||
|
||||
use Engelsystem\Models\User\PasswordReset;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class PasswordResetFactory extends Factory
|
||||
{
|
||||
/** @var string */
|
||||
protected $model = PasswordReset::class;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'token' => md5($this->faker->unique()->password()),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Engelsystem\Models\User;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Engelsystem\Models\User\PersonalData;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class PersonalDataFactory extends Factory
|
||||
{
|
||||
/** @var string */
|
||||
protected $model = PersonalData::class;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$arrival = $this->faker->optional()->dateTimeThisMonth('2 weeks');
|
||||
$departure = $this->faker->optional()->dateTimeThisMonth('2 weeks');
|
||||
|
||||
return [
|
||||
'first_name' => $this->faker->optional(.7)->firstName(),
|
||||
'last_name' => $this->faker->optional()->lastName(),
|
||||
'pronoun' => $this->faker->optional(.3)->pronoun(),
|
||||
'shirt_size' => $this->faker->optional(.9)->shirtSize(),
|
||||
'planned_arrival_date' => $arrival ? Carbon::instance($arrival) : null,
|
||||
'planned_departure_date' => $departure ? Carbon::instance($departure) : null,
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Engelsystem\Models\User;
|
||||
|
||||
use Engelsystem\Models\User\Settings;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class SettingsFactory extends Factory
|
||||
{
|
||||
/** @var string */
|
||||
protected $model = Settings::class;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'language' => $this->faker->locale(),
|
||||
'theme' => $this->faker->numberBetween(1, 20),
|
||||
'email_human' => $this->faker->boolean(),
|
||||
'email_shiftinfo' => $this->faker->boolean(),
|
||||
'email_news' => $this->faker->boolean(),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Engelsystem\Models\User;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Engelsystem\Models\User\State;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class StateFactory extends Factory
|
||||
{
|
||||
/** @var string */
|
||||
protected $model = State::class;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$arrival = $this->faker->optional()->dateTimeThisMonth();
|
||||
|
||||
return [
|
||||
'arrived' => (bool)$arrival,
|
||||
'arrival_date' => $arrival ? Carbon::instance($arrival) : null,
|
||||
'active' => $this->faker->boolean(.3),
|
||||
'force_active' => $this->faker->boolean(.1),
|
||||
'got_shirt' => $this->faker->boolean(),
|
||||
'got_voucher' => $this->faker->numberBetween(0, 10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the user is arrived
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function arrived()
|
||||
{
|
||||
return $this->state(
|
||||
function (array $attributes) {
|
||||
return [
|
||||
'arrived' => true,
|
||||
'arrival_date' => Carbon::instance($this->faker->dateTimeThisMonth()),
|
||||
];
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Engelsystem\Models\User;
|
||||
|
||||
use Engelsystem\Models\User\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/** @var string */
|
||||
protected $model = User::class;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->unique()->userName(),
|
||||
'password' => password_hash($this->faker->password(), PASSWORD_DEFAULT),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'api_key' => md5($this->faker->unique()->password()),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Test\Unit;
|
||||
|
||||
use Faker\Provider\Base;
|
||||
|
||||
class FakerProvider extends Base
|
||||
{
|
||||
/** @var string[] */
|
||||
protected static $pronouns = ['fae', 'ae', 'e', 'ey', 'he', 'per', 'she', 'tey', 'they', 've', 'xe', 'ze', 'zie'];
|
||||
|
||||
/** @var string[] */
|
||||
protected static $shirtSizes = ['S', 'S-G', 'M', 'M-G', 'L', 'L-G', 'XL', 'XL-G', '2XL', '3XL', '4XL'];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function pronoun()
|
||||
{
|
||||
return static::randomElement(static::$pronouns);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function shirtSize(): string
|
||||
{
|
||||
return static::randomElement(static::$shirtSizes);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue