From 13b04b7e53bdda59276ee4aa06479f499bdcead0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Feb 2026 18:33:16 +1030 Subject: [PATCH] fix --- database/factories/ActivityFactory.php | 30 ++++++++++ database/factories/FollowerFactory.php | 28 +++++++++ database/factories/ProfileFactory.php | 45 +++++++++++++++ database/factories/StatusFactory.php | 79 ++++++++++++++++++++++++++ database/factories/UserFactory.php | 56 +++++++++++------- 5 files changed, 218 insertions(+), 20 deletions(-) create mode 100644 database/factories/ActivityFactory.php create mode 100644 database/factories/FollowerFactory.php create mode 100644 database/factories/ProfileFactory.php create mode 100644 database/factories/StatusFactory.php diff --git a/database/factories/ActivityFactory.php b/database/factories/ActivityFactory.php new file mode 100644 index 000000000..99180a3e8 --- /dev/null +++ b/database/factories/ActivityFactory.php @@ -0,0 +1,30 @@ + json_encode(['type' => 'Create']), + 'to_id' => Profile::factory(), + 'from_id' => Profile::factory(), + 'object_type' => 'status', + 'processed_at' => null, + ]; + } + + public function processed(): static + { + return $this->state(fn (array $attributes) => [ + 'processed_at' => now(), + ]); + } +} diff --git a/database/factories/FollowerFactory.php b/database/factories/FollowerFactory.php new file mode 100644 index 000000000..9467ccabc --- /dev/null +++ b/database/factories/FollowerFactory.php @@ -0,0 +1,28 @@ + Profile::factory(), + 'following_id' => Profile::factory(), + 'local_profile' => true, + ]; + } + + public function remote(): static + { + return $this->state(fn (array $attributes) => [ + 'local_profile' => false, + ]); + } +} diff --git a/database/factories/ProfileFactory.php b/database/factories/ProfileFactory.php new file mode 100644 index 000000000..1eda8d406 --- /dev/null +++ b/database/factories/ProfileFactory.php @@ -0,0 +1,45 @@ + User::factory(), + 'username' => str_replace('.', '', fake()->unique()->userName()), + 'name' => fake()->name(), + 'domain' => null, + 'remote_url' => null, + 'is_private' => false, + 'status_count' => 0, + 'following_count' => 0, + 'followers_count' => 0, + 'last_fetched_at' => null, + 'last_status_at' => null, + ]; + } + + public function private(): static + { + return $this->state(fn (array $attributes) => [ + 'is_private' => true, + ]); + } + + public function remote(): static + { + return $this->state(fn (array $attributes) => [ + 'domain' => fake()->domainName(), + 'remote_url' => fake()->url(), + 'user_id' => null, + ]); + } +} diff --git a/database/factories/StatusFactory.php b/database/factories/StatusFactory.php new file mode 100644 index 000000000..88a06ff33 --- /dev/null +++ b/database/factories/StatusFactory.php @@ -0,0 +1,79 @@ + Profile::factory(), + 'type' => 'text', + 'caption' => fake()->sentence(), + 'in_reply_to_id' => null, + 'in_reply_to_profile_id' => null, + 'reblog_of_id' => null, + 'is_nsfw' => false, + 'scope' => 'public', + 'visibility' => 'public', + 'cw_summary' => null, + 'comments_disabled' => false, + 'likes_count' => 0, + 'reblogs_count' => 0, + 'reply_count' => 0, + 'local' => true, + 'place' => null, + ]; + } + + public function photo(): static + { + return $this->state(fn (array $attributes) => [ + 'type' => 'photo', + ]); + } + + public function video(): static + { + return $this->state(fn (array $attributes) => [ + 'type' => 'video', + ]); + } + + public function private(): static + { + return $this->state(fn (array $attributes) => [ + 'scope' => 'private', + 'visibility' => 'private', + ]); + } + + public function unlisted(): static + { + return $this->state(fn (array $attributes) => [ + 'scope' => 'unlisted', + 'visibility' => 'unlisted', + ]); + } + + public function nsfw(): static + { + return $this->state(fn (array $attributes) => [ + 'is_nsfw' => true, + ]); + } + + public function reply(): static + { + return $this->state(fn (array $attributes) => [ + 'type' => 'reply', + 'in_reply_to_id' => Status::factory(), + ]); + } +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index bc8b56bbd..02b2cfae0 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -1,24 +1,40 @@ define(App\User::class, function (Faker $faker) { - return [ - 'name' => $faker->name, - 'username' => str_replace('.', '', $faker->unique()->userName), - 'email' => str_random(8).$faker->unique()->safeEmail, - 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret - 'remember_token' => str_random(10), - ]; -}); +class UserFactory extends Factory +{ + protected $model = User::class; + + public function definition(): array + { + return [ + 'name' => fake()->name(), + 'username' => str_replace('.', '', fake()->unique()->userName()), + 'email' => Str::random(8).fake()->unique()->safeEmail(), + 'password' => Hash::make('password'), + 'remember_token' => Str::random(10), + 'email_verified_at' => now(), + 'last_active_at' => now(), + ]; + } + + public function unverified(): static + { + return $this->state(fn (array $attributes) => [ + 'email_verified_at' => null, + ]); + } + + public function admin(): static + { + return $this->state(fn (array $attributes) => [ + 'is_admin' => true, + ]); + } +}