Skip to content

Commit 9d54b74

Browse files
Drop archived faker package
Signed-off-by: Christoph Wurst <[email protected]>
1 parent 5c35e7d commit 9d54b74

File tree

4 files changed

+102
-98
lines changed

4 files changed

+102
-98
lines changed

Diff for: composer.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"ext-redis": "*",
88
"ext-zip": "1.*",
99
"ext-zlib": "*",
10-
"fzaninotto/faker": "~1.4",
1110
"laravel/framework": "8.80.*",
1211
"laravel/helpers": "^1.3",
1312
"laravel/ui": "^3.1",
@@ -67,6 +66,9 @@
6766
"cs:fix": "php-cs-fixer fix"
6867
},
6968
"config": {
70-
"preferred-install": "dist"
69+
"preferred-install": "dist",
70+
"allow-plugins": {
71+
"composer/package-versions-deprecated": true
72+
}
7173
}
7274
}

Diff for: composer.lock

+57-53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: database/factories/ModelFactory.php

+28-29
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use App\Tasting\TastingSession;
1414
use App\Wine;
1515
use App\WineQuality;
16-
use Faker\Generator as FakeData;
1716

1817
$factory->define(User::class,
1918
function () {
@@ -35,16 +34,16 @@ function () {
3534
$factory->define(Association::class,
3635
function () {
3736
return [
38-
'id' => rand(10000, 99000),
37+
'id' => random_int(10000, 99000),
3938
'name' => str_random(10),
4039
'wuser_username' => null,
4140
];
4241
});
4342

4443
$factory->define(Applicant::class,
45-
function (FakeData $faker) {
44+
function () {
4645
return [
47-
'id' => rand(10000, 999999),
46+
'id' => random_int(10000, 999999),
4847
'association_id' => function () {
4948
return factory(Association::class)->create()->id;
5049
},
@@ -54,23 +53,23 @@ function (FakeData $faker) {
5453
},
5554
'label' => str_random(10),
5655
'title' => 'Dr.',
57-
'firstname' => $faker->firstName,
58-
'lastname' => $faker->lastName,
59-
'phone' => substr($faker->phoneNumber, 0, 20),
60-
'fax' => substr($faker->phoneNumber, 0, 20),
61-
'mobile' => substr($faker->phoneNumber, 0, 20),
62-
'email' => $faker->email,
63-
'web' => substr($faker->url, 0, 50),
56+
'firstname' => str_random(20),
57+
'lastname' => str_random(20),
58+
'phone' => random_int(10000, 100000000),
59+
'fax' => random_int(10000, 100000000),
60+
'mobile' => random_int(10000, 100000000),
61+
'email' => str_random(8) . '@' . str_random(5) . '.com',
62+
'web' => str_random(10) . '.com',
6463
];
6564
});
6665

6766
$factory->define(Address::class,
68-
function (FakeData $faker) {
67+
function () {
6968
return [
70-
'street' => $faker->streetAddress,
71-
'nr' => $faker->numberBetween(1, 300),
72-
'zipcode' => $faker->numberBetween(1000, 9999),
73-
'city' => $faker->city,
69+
'street' => str_random(20),
70+
'nr' => random_int(1, 300),
71+
'zipcode' => random_int(1000, 9999),
72+
'city' => str_random(10),
7473
];
7574
});
7675

@@ -86,12 +85,12 @@ function () {
8685
$factory->define(Wine::class,
8786
function () {
8887
return [
89-
'nr' => rand(1, 1000),
88+
'nr' => random_int(1, 1000),
9089
'label' => str_random(10),
91-
'vintage' => rand(2005, 2020),
92-
'alcohol' => rand(1, 200) / 10,
93-
'acidity' => rand(1, 200) / 10,
94-
'sugar' => rand(1, 300) / 10,
90+
'vintage' => random_int(2005, 2020),
91+
'alcohol' => random_int(1, 200) / 10,
92+
'acidity' => random_int(1, 200) / 10,
93+
'sugar' => random_int(1, 300) / 10,
9594
'approvalnr' => str_random(15),
9695
'winesort_id' => function () {
9796
return factory(WineSort::class)->create()->id;
@@ -102,22 +101,22 @@ function () {
102101
'applicant_id' => function () {
103102
return factory(Applicant::class)->create()->id;
104103
},
105-
'winequality_id' => rand(1, 10), // Hard-coded, but should exist in DB
104+
'winequality_id' => random_int(1, 10), // Hard-coded, but should exist in DB
106105
];
107106
});
108107

109108
$factory->define(WineQuality::class,
110109
function () {
111110
return [
112-
'id' => rand(100, 1000),
111+
'id' => random_int(100, 1000),
113112
'label' => str_random(10),
114113
'abbr' => strtoupper(str_random(3)),
115114
];
116115
});
117116

118117
$factory->define(WineSort::class, function () {
119118
return [
120-
'order' => rand(1, 50000),
119+
'order' => random_int(1, 50000),
121120
'name' => str_random(10),
122121
'quality_allowed' => '[]',
123122
];
@@ -126,11 +125,11 @@ function () {
126125
$factory->define(TastingNumber::class,
127126
function () {
128127
return [
129-
'tastingstage_id' => rand(1, 2),
128+
'tastingstage_id' => random_int(1, 2),
130129
'wine_id' => function () {
131130
return factory(Wine::class)->create()->id;
132131
},
133-
'nr' => rand(1, 5000),
132+
'nr' => random_int(1, 5000),
134133
];
135134
});
136135

@@ -139,8 +138,8 @@ function () {
139138
'competition_id' => function () {
140139
return factory(Competition::class)->create()->id;
141140
},
142-
'tastingstage_id' => rand(1, 2),
143-
'nr' => rand(1, 100),
141+
'tastingstage_id' => random_int(1, 2),
142+
'nr' => random_int(1, 100),
144143
'locked' => false,
145144
];
146145
});
@@ -159,7 +158,7 @@ function () {
159158
'commission_id' => function () {
160159
return factory(Commission::class)->create()->id;
161160
},
162-
'nr' => rand(1, 1000),
161+
'nr' => random_int(1, 1000),
163162
'name' => str_random(10),
164163
'active' => true,
165164
];

Diff for: tests/Integration/Settings/ApplicantsTest.php

+13-14
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use App\MasterData\Association;
2525
use App\MasterData\User;
2626
use function factory;
27-
use Faker\Factory;
27+
use function random_int;
2828
use function str_random;
2929
use Test\BrowserKitTestCase;
3030

@@ -34,7 +34,6 @@ class ApplicantsTest extends BrowserKitTestCase
3434

3535
public function createApplicant()
3636
{
37-
$faker = Factory::create();
3837
$admin = factory(User::class)->states('admin')->create();
3938
$association = factory(Association::class)->create();
4039

@@ -49,25 +48,25 @@ public function createApplicant()
4948
$this->assertRedirectedTo('settings/applicants/create');
5049

5150
// But this time for real
52-
$id = random(10000, 99999);
51+
$id = random_int(10000, 99999);
5352
$this->post('settings/applicants/create',
5453
[
5554
'id' => $id,
5655
'association_id' => $association->id,
5756
'wuser_username' => 'none',
5857
'label' => str_random(10),
5958
'title' => 'Dr.',
60-
'firstname' => $faker->firstName,
61-
'lastname' => $faker->lastName,
62-
'phone' => $faker->phoneNumber,
63-
'fax' => $faker->phoneNumber,
64-
'mobile' => $faker->phoneNumber,
65-
'email' => $faker->email,
66-
'web' => $faker->url,
67-
'street' => $faker->streetAddress,
68-
'nr' => $faker->numberBetween(1, 300),
69-
'zipcode' => $faker->numberBetween(1000, 9999),
70-
'city' => $faker->city,
59+
'firstname' => str_random(10),
60+
'lastname' => str_random(10),
61+
'phone' => random_int(10000, 100000000),
62+
'fax' => random_int(10000, 100000000),
63+
'mobile' => random_int(10000, 100000000),
64+
'email' => str_random(8) . '@' . str_random(5) . '.com',
65+
'web' => str_random(10) . '.com',
66+
'street' => str_random(20),
67+
'nr' => random_int(1, 300),
68+
'zipcode' => random_int(1000, 9999),
69+
'city' => str_random(10),
7170
]);
7271
$this->assertRedirectedTo('settings/applicants');
7372

0 commit comments

Comments
 (0)