Tripal
All Classes Files Functions Variables Modules Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest Class Reference
Inheritance diagram for Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest:
Inheritance graph
[legend]
Collaboration diagram for Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest:
Collaboration graph
[legend]

Public Member Functions

 testTripalDbxSchemaConstructor ()
 
 testTripalDbxSchemaPrefixInfo ()
 
 testTripalDbxSchemaScenario1 ()
 

Static Public Member Functions

static tearDownAfterClass ()
 

Protected Member Functions

 setUp ()
 
 getTripalDbxSchemaMock ($database_or_schema_name)
 
 allowTestSchemas ()
 

Protected Attributes

 $proConfigFactory
 
 $configFactory
 
 $proConfig
 
 $config
 

Static Protected Attributes

static $modules = ['tripal']
 
static $testSchemas = []
 
static $db = NULL
 

Detailed Description

Tests for Tripal DBX schema on a real database.

See also
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Schema.php/class/Schema/9.2.x

@coversDefaultClass \Drupal\tripal\TripalDBX\TripalDbxSchema

@group Tripal @group Tripal TripalDBX @group Tripal TripalDBX Schema

Member Function Documentation

◆ allowTestSchemas()

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::allowTestSchemas ( )
protected

Allow a test to use reserved default test schema names.

◆ getTripalDbxSchemaMock()

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::getTripalDbxSchemaMock (   $database_or_schema_name)
protected

Builds an initialized TripalDbxSchema mock.

Parameters
$database_or_schema_nameEither a \Drupal\tripal\TripalDBX\TripalDbxConnection object (or mock) or a schema name to use.

◆ setUp()

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::setUp ( )
protected

{}

◆ tearDownAfterClass()

static Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::tearDownAfterClass ( )
static

{}

◆ testTripalDbxSchemaConstructor()

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::testTripalDbxSchemaConstructor ( )

Tests constructor.

@cover ::__construct

◆ testTripalDbxSchemaPrefixInfo()

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::testTripalDbxSchemaPrefixInfo ( )

Tests getPrefixInfo.

@cover ::getPrefixInfo

◆ testTripalDbxSchemaScenario1()

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::testTripalDbxSchemaScenario1 ( )

Test a scenario.

@cover ::getSchemaName @cover ::schemaExists @cover ::createSchema @cover ::getSchemaSize @cover ::findTables @cover ::tableExists @cover ::fieldExists @cover ::indexExists @cover ::constraintExists @cover ::primaryKeyExists @cover ::foreignKeyConstraintExists @cover ::sequenceExists @cover ::functionExists @cover ::createTable @cover ::renameTable @cover ::changeField @cover ::addIndex @cover ::dropTable @cover ::getTables @cover ::getTableDef @cover ::getTableDdl @cover ::renameSchema @cover ::cloneSchema @cover ::dropSchema

 These tests do not work in a mocked setting.
 However, when tested manually with the Chado implementation
 they do work so we're commenting them out for now.

Create a table. $scmock->createTable( 'table_1', [ "fields" => [ "thing" => [ "type" => "text", "not null" => TRUE, "pgsql_type" => "integer", ], ], ] ); $exists = $scmock->tableExists('table_1'); $this->assertTrue($exists, 'Table "table_1" was created.');

Rename table. $scmock->renameTable('table_1', 'table_1_renamed'); $exists = $scmock->tableExists('table_1'); $this->assertFalse($exists, 'Table "table_1" renamed into something else as it no longer exists.'); $exists = $scmock->tableExists('table_1_renamed'); $this->assertTrue($exists, 'Table "table_1_renamed" is the new table name since it does exist.');

Change field. $scmock->changeField( 'table_1_renamed', 'thing', 'thing_renamed', [ "type" => "text", "not null" => FALSE, "pgsql_type" => "bigint", ] ); $exists = $scmock->fieldExists('table_1_renamed', 'thing_renamed'); $this->assertTrue($exists, 'Field "table_1_renamed.thing_renamed" exists.');

Add an index. $scmock->addIndex( 'table_1_renamed', 'table_1_renamed_thing_renamed', ['thing_renamed'], [ "fields" => [ "thing_renamed" => [ "type" => "text", "not null" => TRUE, "pgsql_type" => "bigint", ], ], ] ); $exists = $scmock->indexExists('table_1_renamed', 'table_1_renamed_thing_renamed'); $this->assertTrue($exists, 'Index "table_1_renamed_thing_renamed__idx" exists.');

Drop Table $success = $scmock->dropTable('table_1_renamed'); $this->assertTrue($success, 'Table "table_1_renamed" dropped.'); $exists = $scmock->tableExists('table_1_renamed'); $this->assertFalse($exists, 'Table "table_1_renamed" does not exist.');

Member Data Documentation

◆ $modules

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::$modules = ['tripal']
staticprotected

{}

◆ $proConfigFactory

Drupal\Tests\tripal\Kernel\TripalDBX\SchemaTest::$proConfigFactory
protected

Test members.

"pro*" members are prophesize objects while their "non-pro*" equivqlent are the revealed objects.


The documentation for this class was generated from the following file: