diff --git a/tests/modules/jsonapi_schema_test.module b/tests/modules/jsonapi_schema_test.module
index b2f092f..7b575f0 100644
--- a/tests/modules/jsonapi_schema_test.module
+++ b/tests/modules/jsonapi_schema_test.module
@@ -4,7 +4,8 @@
  * @file
  * Contains jsonapi_schema_test.module.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\jsonapi_schema_test\Hook\JsonapiSchemaTestHooks;
 use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Field\BaseFieldDefinition;
@@ -13,23 +14,10 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
 /**
  * Implements hook_entity_base_field_info().
  */
-function jsonapi_schema_test_entity_base_field_info(EntityTypeInterface $entity_type) {
-  $fields = [];
-  if ($entity_type->id() == 'node') {
-
-    // Add a list_string base field with an allowed values function.
-    $field = BaseFieldDefinition::create('list_string');
-    $field->setLabel('Test allowed values function');
-    $field->setDescription('Test allowed values function description');
-    $field->setCardinality(-1);
-    $field->setSetting('allowed_values', [
-      'value1' => 'Value 1',
-      'value2' => 'Value 2',
-      'value3' => 'Value 3',
-    ]);
-    $fields['test_allowed_values_function'] = $field;
-  }
-  return $fields;
+#[LegacyHook]
+function jsonapi_schema_test_entity_base_field_info(EntityTypeInterface $entity_type)
+{
+    return \Drupal::service(JsonapiSchemaTestHooks::class)->entityBaseFieldInfo($entity_type);
 }
 
 /**
diff --git a/tests/modules/jsonapi_schema_test.services.yml b/tests/modules/jsonapi_schema_test.services.yml
new file mode 100644
index 0000000..09feffb
--- /dev/null
+++ b/tests/modules/jsonapi_schema_test.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\jsonapi_schema_test\Hook\JsonapiSchemaTestHooks:
+    class: Drupal\jsonapi_schema_test\Hook\JsonapiSchemaTestHooks
+    autowire: true
diff --git a/tests/modules/src/Hook/JsonapiSchemaTestHooks.php b/tests/modules/src/Hook/JsonapiSchemaTestHooks.php
new file mode 100644
index 0000000..3191867
--- /dev/null
+++ b/tests/modules/src/Hook/JsonapiSchemaTestHooks.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Drupal\jsonapi_schema_test\Hook;
+
+use Drupal\Core\Entity\ContentEntityInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
+use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for jsonapi_schema_test.
+ */
+class JsonapiSchemaTestHooks
+{
+    /**
+     * Implements hook_entity_base_field_info().
+     */
+    #[Hook('entity_base_field_info')]
+    public static function entityBaseFieldInfo(\Drupal\Core\Entity\EntityTypeInterface $entity_type)
+    {
+        $fields = [
+        ];
+        if ($entity_type->id() == 'node') {
+            // Add a list_string base field with an allowed values function.
+            $field = \Drupal\Core\Field\BaseFieldDefinition::create('list_string');
+            $field->setLabel('Test allowed values function');
+            $field->setDescription('Test allowed values function description');
+            $field->setCardinality(-1);
+            $field->setSetting('allowed_values', [
+                'value1' => 'Value 1',
+                'value2' => 'Value 2',
+                'value3' => 'Value 3',
+            ]);
+            $fields['test_allowed_values_function'] = $field;
+        }
+        return $fields;
+    }
+}
