mirror of https://github.com/pixelfed/pixelfed
fix
parent
72fcc173de
commit
13b04b7e53
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Activity;
|
||||||
|
use App\Profile;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class ActivityFactory extends Factory
|
||||||
|
{
|
||||||
|
protected $model = Activity::class;
|
||||||
|
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'data' => 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(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Follower;
|
||||||
|
use App\Profile;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class FollowerFactory extends Factory
|
||||||
|
{
|
||||||
|
protected $model = Follower::class;
|
||||||
|
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'profile_id' => Profile::factory(),
|
||||||
|
'following_id' => Profile::factory(),
|
||||||
|
'local_profile' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remote(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn (array $attributes) => [
|
||||||
|
'local_profile' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Profile;
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class ProfileFactory extends Factory
|
||||||
|
{
|
||||||
|
protected $model = Profile::class;
|
||||||
|
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'user_id' => 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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Profile;
|
||||||
|
use App\Status;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class StatusFactory extends Factory
|
||||||
|
{
|
||||||
|
protected $model = Status::class;
|
||||||
|
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'profile_id' => 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(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,24 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Faker\Generator as Faker;
|
namespace Database\Factories;
|
||||||
|
|
||||||
/*
|
use App\User;
|
||||||
|--------------------------------------------------------------------------
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
| Model Factories
|
use Illuminate\Support\Facades\Hash;
|
||||||
|--------------------------------------------------------------------------
|
use Illuminate\Support\Str;
|
||||||
|
|
|
||||||
| This directory should contain each of the model factory definitions for
|
|
||||||
| your application. Factories provide a convenient way to generate new
|
|
||||||
| model instances for testing / seeding your application's database.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
$factory->define(App\User::class, function (Faker $faker) {
|
class UserFactory extends Factory
|
||||||
return [
|
{
|
||||||
'name' => $faker->name,
|
protected $model = User::class;
|
||||||
'username' => str_replace('.', '', $faker->unique()->userName),
|
|
||||||
'email' => str_random(8).$faker->unique()->safeEmail,
|
public function definition(): array
|
||||||
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
|
{
|
||||||
'remember_token' => str_random(10),
|
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue