Skip to content

Commit 6d1bcf6

Browse files
committed
Use Faker methods
1 parent 46a2db9 commit 6d1bcf6

29 files changed

+103
-103
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"illuminate/console": "^10.0",
1414
"illuminate/filesystem": "^10.0",
1515
"illuminate/support": "^10.0",
16-
"laravel-shift/faker-registry": "^0.2.0",
16+
"laravel-shift/faker-registry": "^0.3.0",
1717
"symfony/yaml": "^6.2"
1818
},
1919
"require-dev": {

src/Generators/FactoryGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ protected function buildDefinition(Model $model): string
167167
$faker = FakerRegistry::fakerData($column->name()) ?? (FakerRegistry::fakerDataType($type) ?? FakerRegistry::fakerDataType($column->dataType()));
168168

169169
if ($faker === null) {
170-
$faker = 'word';
170+
$faker = 'word()';
171171
}
172172

173-
if (($faker === 'word') && (!empty($column->attributes()))) {
173+
if ($faker === 'word()' && !empty($column->attributes())) {
174174
$faker = sprintf("regexify('[A-Za-z0-9]{%s}')", current($column->attributes()));
175175
}
176176

tests/fixtures/factories/all-column-types.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,41 @@ public function definition(): array
2222
{
2323
return [
2424
'bigInteger' => $this->faker->numberBetween(-100000, 100000),
25-
'binary' => $this->faker->sha256,
26-
'boolean' => $this->faker->boolean,
27-
'char' => $this->faker->randomLetter,
25+
'binary' => $this->faker->sha256(),
26+
'boolean' => $this->faker->boolean(),
27+
'char' => $this->faker->randomLetter(),
2828
'date' => $this->faker->date(),
2929
'dateTime' => $this->faker->dateTime(),
3030
'dateTimeTz' => $this->faker->dateTime(),
3131
'decimal' => $this->faker->randomFloat(0, 0, 9999999999.),
3232
'double' => $this->faker->randomFloat(0, 0, 9999999999.),
3333
'enum' => $this->faker->randomElement(["1","2","3"]),
3434
'float' => $this->faker->randomFloat(0, 0, 9999999999.),
35-
'fullText' => $this->faker->text,
36-
'geometry' => $this->faker->word,
37-
'geometryCollection' => $this->faker->word,
35+
'fullText' => $this->faker->text(),
36+
'geometry' => $this->faker->word(),
37+
'geometryCollection' => $this->faker->word(),
3838
'integer' => $this->faker->numberBetween(-10000, 10000),
39-
'ipAddress' => $this->faker->ipv4,
39+
'ipAddress' => $this->faker->ipv4(),
4040
'json' => '{}',
4141
'jsonb' => '{}',
42-
'lineString' => $this->faker->word,
43-
'longText' => $this->faker->text,
44-
'macAddress' => $this->faker->macAddress,
42+
'lineString' => $this->faker->word(),
43+
'longText' => $this->faker->text(),
44+
'macAddress' => $this->faker->macAddress(),
4545
'mediumInteger' => $this->faker->numberBetween(-10000, 10000),
46-
'mediumText' => $this->faker->text,
47-
'morphs_id' => $this->faker->randomDigitNotNull,
48-
'morphs_type' => $this->faker->word,
49-
'uuidMorphs' => $this->faker->word,
50-
'multiLineString' => $this->faker->word,
51-
'multiPoint' => $this->faker->word,
52-
'multiPolygon' => $this->faker->word,
53-
'point' => $this->faker->word,
54-
'polygon' => $this->faker->word,
46+
'mediumText' => $this->faker->text(),
47+
'morphs_id' => $this->faker->randomDigitNotNull(),
48+
'morphs_type' => $this->faker->word(),
49+
'uuidMorphs' => $this->faker->word(),
50+
'multiLineString' => $this->faker->word(),
51+
'multiPoint' => $this->faker->word(),
52+
'multiPolygon' => $this->faker->word(),
53+
'point' => $this->faker->word(),
54+
'polygon' => $this->faker->word(),
5555
'rememberToken' => Str::random(10),
5656
'set' => $this->faker->randomElement(["1","2","3"]),
5757
'smallInteger' => $this->faker->numberBetween(-1000, 1000),
58-
'string' => $this->faker->word,
59-
'text' => $this->faker->text,
58+
'string' => $this->faker->word(),
59+
'text' => $this->faker->text(),
6060
'time' => $this->faker->time(),
6161
'timeTz' => $this->faker->time(),
6262
'timestamp' => $this->faker->dateTime(),
@@ -67,8 +67,8 @@ public function definition(): array
6767
'unsignedInteger' => $this->faker->randomNumber(),
6868
'unsignedMediumInteger' => $this->faker->randomNumber(),
6969
'unsignedSmallInteger' => $this->faker->randomNumber(),
70-
'unsignedTinyInteger' => $this->faker->randomDigitNotNull,
71-
'uuid' => $this->faker->uuid,
70+
'unsignedTinyInteger' => $this->faker->randomDigitNotNull(),
71+
'uuid' => $this->faker->uuid(),
7272
'year' => $this->faker->year(),
7373
];
7474
}

tests/fixtures/factories/model-key-constraints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function definition(): array
2424
{
2525
return [
2626
'user_id' => User::factory(),
27-
'external_id' => $this->faker->word,
27+
'external_id' => $this->faker->word(),
2828
'sub_id' => Subscription::factory(),
2929
'expires_at' => $this->faker->dateTime(),
3030
'meta' => '[]',

tests/fixtures/factories/model-modifiers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public function definition(): array
2222
{
2323
return [
2424
'title' => $this->faker->sentence(4),
25-
'name' => $this->faker->name,
25+
'name' => $this->faker->name(),
2626
'content' => $this->faker->paragraphs(3, true),
2727
'amount' => $this->faker->randomFloat(3, 0, 999999.999),
2828
'total' => $this->faker->randomFloat(2, 0, 99999999.99),
2929
'overflow' => $this->faker->randomFloat(30, 0, 99999999999999999999999999999999999.999999999999999999999999999999),
30-
'ssn' => $this->faker->ssn,
30+
'ssn' => $this->faker->ssn(),
3131
'role' => $this->faker->randomElement(["user","admin","owner"]),
3232
];
3333
}

tests/fixtures/factories/nested-components.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class UserFactory extends Factory
2121
public function definition(): array
2222
{
2323
return [
24-
'name' => $this->faker->name,
25-
'password' => $this->faker->password,
24+
'name' => $this->faker->name(),
25+
'password' => $this->faker->password(),
2626
];
2727
}
2828
}

tests/fixtures/factories/phone.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class PhoneFactory extends Factory
2222
public function definition(): array
2323
{
2424
return [
25-
'label' => $this->faker->word,
25+
'label' => $this->faker->word(),
2626
'user_id' => User::factory(),
27-
'phone_number' => $this->faker->phoneNumber,
27+
'phone_number' => $this->faker->phoneNumber(),
2828
'type' => $this->faker->randomElement(["home","cell"]),
2929
'status' => $this->faker->randomElement(["archived","deleted"]),
30-
'foo_id' => $this->faker->randomDigitNotNull,
31-
'foo_type' => $this->faker->word,
30+
'foo_id' => $this->faker->randomDigitNotNull(),
31+
'foo_type' => $this->faker->word(),
3232
'tag' => $this->faker->regexify('[A-Za-z0-9]{3}'),
3333
];
3434
}

tests/fixtures/factories/post-configured.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function definition(): array
2424
return [
2525
'title' => $this->faker->sentence(4),
2626
'author_id' => Author::factory(),
27-
'author_bio' => $this->faker->text,
27+
'author_bio' => $this->faker->text(),
2828
'content' => $this->faker->paragraphs(3, true),
2929
'published_at' => $this->faker->dateTime(),
3030
'updated_at' => $this->faker->dateTime(),

tests/fixtures/factories/post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function definition(): array
2424
return [
2525
'title' => $this->faker->sentence(4),
2626
'author_id' => Author::factory(),
27-
'author_bio' => $this->faker->text,
27+
'author_bio' => $this->faker->text(),
2828
'content' => $this->faker->paragraphs(3, true),
2929
'published_at' => $this->faker->dateTime(),
3030
'updated_at' => $this->faker->dateTime(),

tests/fixtures/factories/resource-statements.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class UserFactory extends Factory
2121
public function definition(): array
2222
{
2323
return [
24-
'name' => $this->faker->name,
25-
'email' => $this->faker->safeEmail,
26-
'password' => $this->faker->password,
24+
'name' => $this->faker->name(),
25+
'email' => $this->faker->safeEmail(),
26+
'password' => $this->faker->password(),
2727
'remember_token' => Str::random(10),
2828
];
2929
}

0 commit comments

Comments
 (0)