You are here

public static function TestDatabase::testingSchema in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Test/TestDatabase.php \Drupal\Core\Test\TestDatabase::testingSchema()

Defines the database schema for run-tests.sh and simpletest module.

@internal

Return value

array Array suitable for use in a hook_schema() implementation.

1 call to TestDatabase::testingSchema()
simpletest_schema in core/modules/simpletest/simpletest.install
Implements hook_schema().

File

core/lib/Drupal/Core/Test/TestDatabase.php, line 320

Class

TestDatabase
Provides helper methods for interacting with the fixture database.

Namespace

Drupal\Core\Test

Code

public static function testingSchema() {
  $schema['simpletest'] = [
    'description' => 'Stores simpletest messages',
    'fields' => [
      'message_id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique simpletest message ID.',
      ],
      'test_id' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Test ID, messages belonging to the same ID are reported together',
      ],
      'test_class' => [
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The name of the class that created this message.',
      ],
      'status' => [
        'type' => 'varchar',
        'length' => 9,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Message status. Core understands pass, fail, exception.',
      ],
      'message' => [
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'The message itself.',
      ],
      'message_group' => [
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The message group this message belongs to. For example: warning, browser, user.',
      ],
      'function' => [
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Name of the assertion function or method that created this message.',
      ],
      'line' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Line number on which the function is called.',
      ],
      'file' => [
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Name of the file where the function is called.',
      ],
    ],
    'primary key' => [
      'message_id',
    ],
    'indexes' => [
      'reporter' => [
        'test_class',
        'message_id',
      ],
    ],
  ];
  $schema['simpletest_test_id'] = [
    'description' => 'Stores simpletest test IDs, used to auto-increment the test ID so that a fresh test ID is used.',
    'fields' => [
      'test_id' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique simpletest ID used to group test results together. Each time a set of tests
                            are run a new test ID is used.',
      ],
      'last_prefix' => [
        'type' => 'varchar',
        'length' => 60,
        'not null' => FALSE,
        'default' => '',
        'description' => 'The last database prefix used during testing.',
      ],
    ],
    'primary key' => [
      'test_id',
    ],
  ];
  return $schema;
}