prepareDatabase([ 'users' => [ $this->adminUser(), ], 'settings' => [ ['key' => 'display_name_driver', 'value' => 'custom'], ], ]); } /** * @test */ public function username_display_name_driver_used_by_default() { $this->prepDb(); $user = User::find(1); $this->assertEquals('admin', $user->displayName); } /** * @test */ public function can_use_custom_display_name_driver() { $this->extend( (new Extend\User) ->displayNameDriver('custom', CustomDisplayNameDriver::class) ); $this->prepDb(); $user = User::find(1); $this->assertEquals('admin@machine.local$$$suffix', $user->displayName); } } class CustomDisplayNameDriver implements DriverInterface { public function displayName(User $user): string { return $user->email.'$$$suffix'; } }