mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-28 03:12:36 +03:00
DB: Updated handling of deleted user ID handling in DB
Updated uses of user ID to nullify on delete. Added testing to cover deletion of user relations. Added model factories to support changes and potential other tests. Cleans existing ID references in the DB via migration.
This commit is contained in:
34
database/factories/Activity/Models/ActivityFactory.php
Normal file
34
database/factories/Activity/Models/ActivityFactory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Activity\Models;
|
||||
|
||||
use BookStack\Activity\ActivityType;
|
||||
use BookStack\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\BookStack\Activity\Models\Activity>
|
||||
*/
|
||||
class ActivityFactory extends Factory
|
||||
{
|
||||
protected $model = \BookStack\Activity\Models\Activity::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$activities = ActivityType::all();
|
||||
$activity = $activities[array_rand($activities)];
|
||||
return [
|
||||
'type' => $activity,
|
||||
'detail' => 'Activity detail for ' . $activity,
|
||||
'user_id' => User::factory(),
|
||||
'ip' => $this->faker->ipv4(),
|
||||
'loggable_id' => null,
|
||||
'loggable_type' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user