class SchemaTest
Same name in this branch
- 9 core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest
- 9 core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest
- 9 core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest
- 10 core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest
- 10 core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest
- 10 core/modules/pgsql/tests/src/Unit/SchemaTest.php \Drupal\Tests\pgsql\Unit\SchemaTest
- 10 core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest
- 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php \Drupal\Tests\sqlite\Kernel\sqlite\SchemaTest
- 11.x core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php \Drupal\Tests\mysql\Kernel\mysql\SchemaTest
- 11.x core/modules/pgsql/tests/src/Unit/SchemaTest.php \Drupal\Tests\pgsql\Unit\SchemaTest
- 11.x core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\SchemaTest
@coversDefaultClass \Drupal\pgsql\Driver\Database\pgsql\Schema @group Database
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait
- class \Drupal\Tests\pgsql\Unit\SchemaTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of SchemaTest
File
-
core/
modules/ pgsql/ tests/ src/ Unit/ SchemaTest.php, line 14
Namespace
Drupal\Tests\pgsql\UnitView source
class SchemaTest extends UnitTestCase {
/**
* The PostgreSql DB connection.
*
* @var \PHPUnit\Framework\MockObject\MockObject|\Drupal\pgsql\Driver\Database\pgsql\Connection
*/
protected $connection;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->connection = $this->getMockBuilder('\\Drupal\\pgsql\\Driver\\Database\\pgsql\\Connection')
->disableOriginalConstructor()
->getMock();
}
/**
* Tests whether the actual constraint name is correctly computed.
*
* @param string $table_name
* The table name the constrained column belongs to.
* @param string $name
* The constraint name.
* @param string $expected
* The expected computed constraint name.
*
* @covers ::constraintExists
* @dataProvider providerComputedConstraintName
*/
public function testComputedConstraintName($table_name, $name, $expected) {
$max_identifier_length = 63;
$schema = new Schema($this->connection);
$statement = $this->createMock('\\Drupal\\Core\\Database\\StatementInterface');
$statement->expects($this->any())
->method('fetchField')
->willReturn($max_identifier_length);
$this->connection
->expects($this->exactly(2))
->method('query')
->withConsecutive([
$this->anything(),
], [
"SELECT 1 FROM pg_constraint WHERE conname = '{$expected}'",
])
->willReturnOnConsecutiveCalls($statement, $this->createMock('\\Drupal\\Core\\Database\\StatementInterface'));
$schema->constraintExists($table_name, $name);
}
/**
* Data provider for ::testComputedConstraintName().
*/
public function providerComputedConstraintName() {
return [
[
'user_field_data',
'pkey',
'user_field_data____pkey',
],
[
'user_field_data',
'name__key',
'user_field_data__name__key',
],
[
'user_field_data',
'a_very_very_very_very_super_long_field_name__key',
'drupal_WW_a8TlbZ3UQi20UTtRlJFaIeSa6FEtQS5h4NRA3UeU_key',
],
];
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |||
SchemaTest::$connection | protected | property | The PostgreSql DB connection. | |||
SchemaTest::providerComputedConstraintName | public | function | Data provider for ::testComputedConstraintName(). | |||
SchemaTest::setUp | protected | function | Overrides UnitTestCase::setUp | |||
SchemaTest::testComputedConstraintName | public | function | Tests whether the actual constraint name is correctly computed. | |||
UnitTestCase::$randomGenerator | protected | property | The random generator. | |||
UnitTestCase::$root | protected | property | The app root. | 1 | ||
UnitTestCase::assertArrayEquals | Deprecated | protected | function | Asserts if two arrays are equal by sorting them first. | ||
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |||
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |||
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |||
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |||
UnitTestCase::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |||
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |||
UnitTestCase::randomMachineName | public | function | Generates a unique random string containing letters and numbers. | |||
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.