Skip to content

Commit

Permalink
Add testSchemaCacheExtreme. (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 5, 2023
1 parent f546753 commit efe916f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/Common/CommonSchemaTest.php
Expand Up @@ -561,6 +561,45 @@ public function testSchemaCache(): void
$db->createCommand()->renameTable('type_test', 'type')->execute();
}

/**
* @throws Exception
* @throws InvalidConfigException
*/
public function testSchemaCacheExtreme(): void
{
$db = $this->getConnection(true);

$command = $db->createCommand();
$schema = $db->getSchema();
$schema->schemaCacheEnable(true);

if ($schema->getTableSchema('{{test_schema_cache}}') !== null) {
$command->dropTable('{{test_schema_cache}}')->execute();
}

$command->createTable('{{test_schema_cache}}', ['int1' => 'integer not null'])->execute();

$schemaNotCache = $schema->getTableSchema('{{test_schema_cache}}', true);

$this->assertNotNull($schemaNotCache);

$schemaCached = $schema->getTableSchema('{{test_schema_cache}}');

$this->assertNotNull($schemaCached);
$this->assertSame($schemaCached, $schemaNotCache);

for ($i = 2; $i <= 20; $i++) {
$command->addColumn('{{test_schema_cache}}', 'int' . $i, 'integer not null')->execute();

$schemaCached = $schema->getTableSchema('{{test_schema_cache}}');

$this->assertNotNull($schemaCached);
$this->assertNotSame($schemaCached, $schemaNotCache);
}

$this->assertCount(20, $schemaCached->getColumns());
}

/**
* @dataProvider \Yiisoft\Db\Tests\Provider\SchemaProvider::tableSchemaCachePrefixes()
*/
Expand Down

0 comments on commit efe916f

Please sign in to comment.