Use faker methods instead of properties

This commit is contained in:
Lance Pioch 2024-03-19 16:47:02 -04:00
parent c124d403ff
commit d4d3ffc96c
10 changed files with 22 additions and 22 deletions

View File

@ -21,7 +21,7 @@ class AllocationFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'ip' => $this->faker->unique()->ipv4, 'ip' => $this->faker->unique()->ipv4(),
'port' => $this->faker->unique()->numberBetween(1024, 65535), 'port' => $this->faker->unique()->numberBetween(1024, 65535),
]; ];
} }

View File

@ -23,7 +23,7 @@ class BackupFactory extends Factory
{ {
return [ return [
'uuid' => Uuid::uuid4()->toString(), 'uuid' => Uuid::uuid4()->toString(),
'name' => $this->faker->sentence, 'name' => $this->faker->sentence(),
'disk' => Backup::ADAPTER_DAEMON, 'disk' => Backup::ADAPTER_DAEMON,
'is_successful' => true, 'is_successful' => true,
'created_at' => CarbonImmutable::now(), 'created_at' => CarbonImmutable::now(),

View File

@ -21,11 +21,11 @@ class DatabaseHostFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'name' => $this->faker->colorName, 'name' => $this->faker->colorName(),
'host' => $this->faker->unique()->ipv4, 'host' => $this->faker->unique()->ipv4(),
'port' => 3306, 'port' => 3306,
'username' => $this->faker->colorName, 'username' => $this->faker->colorName(),
'password' => Crypt::encrypt($this->faker->word), 'password' => Crypt::encrypt($this->faker->word()),
]; ];
} }
} }

View File

@ -22,7 +22,7 @@ class EggFactory extends Factory
{ {
return [ return [
'uuid' => Uuid::uuid4()->toString(), 'uuid' => Uuid::uuid4()->toString(),
'name' => $this->faker->name, 'name' => $this->faker->name(),
'description' => implode(' ', $this->faker->sentences()), 'description' => implode(' ', $this->faker->sentences()),
'startup' => 'java -jar test.jar', 'startup' => 'java -jar test.jar',
]; ];

View File

@ -21,10 +21,10 @@ class EggVariableFactory extends Factory
public function definition(): array public function definition(): array
{ {
return [ return [
'name' => $this->faker->unique()->firstName, 'name' => $this->faker->unique()->firstName(),
'description' => $this->faker->sentence(), 'description' => $this->faker->sentence(),
'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], $this->faker->words(2, true))), 'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], $this->faker->words(2, true))),
'default_value' => $this->faker->colorName, 'default_value' => $this->faker->colorName(),
'user_viewable' => 0, 'user_viewable' => 0,
'user_editable' => 0, 'user_editable' => 0,
'rules' => 'required|string', 'rules' => 'required|string',

View File

@ -26,7 +26,7 @@ class NodeFactory extends Factory
'uuid' => Uuid::uuid4()->toString(), 'uuid' => Uuid::uuid4()->toString(),
'public' => true, 'public' => true,
'name' => 'FactoryNode_' . Str::random(10), 'name' => 'FactoryNode_' . Str::random(10),
'fqdn' => $this->faker->unique()->ipv4, 'fqdn' => $this->faker->unique()->ipv4(),
'scheme' => 'http', 'scheme' => 'http',
'behind_proxy' => false, 'behind_proxy' => false,
'memory' => 1024, 'memory' => 1024,

View File

@ -27,7 +27,7 @@ class ServerFactory extends Factory
return [ return [
'uuid' => Uuid::uuid4()->toString(), 'uuid' => Uuid::uuid4()->toString(),
'uuidShort' => Str::lower(Str::random(8)), 'uuidShort' => Str::lower(Str::random(8)),
'name' => $this->faker->firstName, 'name' => $this->faker->firstName(),
'description' => implode(' ', $this->faker->sentences()), 'description' => implode(' ', $this->faker->sentences()),
'skip_scripts' => 0, 'skip_scripts' => 0,
'status' => null, 'status' => null,

View File

@ -27,10 +27,10 @@ class UserFactory extends Factory
return [ return [
'external_id' => null, 'external_id' => null,
'uuid' => Uuid::uuid4()->toString(), 'uuid' => Uuid::uuid4()->toString(),
'username' => $this->faker->userName . '_' . Str::random(10), 'username' => $this->faker->userName() . '_' . Str::random(10),
'email' => Str::random(32) . '@example.com', 'email' => Str::random(32) . '@example.com',
'name_first' => $this->faker->firstName, 'name_first' => $this->faker->firstName(),
'name_last' => $this->faker->lastName, 'name_last' => $this->faker->lastName(),
'password' => $password ?: $password = bcrypt('password'), 'password' => $password ?: $password = bcrypt('password'),
'language' => 'en', 'language' => 'en',
'root_admin' => false, 'root_admin' => false,

View File

@ -24,7 +24,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount($permissions); [$user, $server] = $this->generateTestAccount($permissions);
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email = $this->faker->email, 'email' => $email = $this->faker->email(),
'permissions' => [ 'permissions' => [
Permission::ACTION_USER_CREATE, Permission::ACTION_USER_CREATE,
], ],
@ -61,7 +61,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
]); ]);
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $this->faker->email, 'email' => $this->faker->email(),
'permissions' => [ 'permissions' => [
Permission::ACTION_USER_CREATE, Permission::ACTION_USER_CREATE,
Permission::ACTION_USER_UPDATE, // This permission is not assigned to the subuser. Permission::ACTION_USER_UPDATE, // This permission is not assigned to the subuser.
@ -112,7 +112,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
/** @var \App\Models\User $existing */ /** @var \App\Models\User $existing */
$existing = User::factory()->create(['email' => $this->faker->email]); $existing = User::factory()->create(['email' => $this->faker->email()]);
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $existing->email, 'email' => $existing->email,
@ -135,7 +135,7 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
[$user, $server] = $this->generateTestAccount(); [$user, $server] = $this->generateTestAccount();
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [ $response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => $email = $this->faker->email, 'email' => $email = $this->faker->email(),
'permissions' => [ 'permissions' => [
Permission::ACTION_USER_CREATE, Permission::ACTION_USER_CREATE,
], ],

View File

@ -76,8 +76,8 @@ class ServerCreationServiceTest extends IntegrationTestCase
]); ]);
$data = [ $data = [
'name' => $this->faker->name, 'name' => $this->faker->name(),
'description' => $this->faker->sentence, 'description' => $this->faker->sentence(),
'owner_id' => $user->id, 'owner_id' => $user->id,
'memory' => 256, 'memory' => 256,
'swap' => 128, 'swap' => 128,
@ -162,8 +162,8 @@ class ServerCreationServiceTest extends IntegrationTestCase
]); ]);
$data = [ $data = [
'name' => $this->faker->name, 'name' => $this->faker->name(),
'description' => $this->faker->sentence, 'description' => $this->faker->sentence(),
'owner_id' => $user->id, 'owner_id' => $user->id,
'allocation_id' => $allocation->id, 'allocation_id' => $allocation->id,
'node_id' => $allocation->node_id, 'node_id' => $allocation->node_id,