|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Tests; |
|
6
|
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
|
|
9
|
|
|
abstract class AbstractSchemaCache extends TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
public function testSchemaCache(): void |
|
12
|
|
|
{ |
|
13
|
|
|
$db = $this->getConnection(true); |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
$schema = $db->getSchema(); |
|
16
|
|
|
$schema->schemaCacheEnable(true); |
|
17
|
|
|
$noCacheTable = $schema->getTableSchema('type', true); |
|
18
|
|
|
$cachedTable = $schema->getTableSchema('type', false); |
|
19
|
|
|
|
|
20
|
|
|
$this->assertSame($noCacheTable, $cachedTable); |
|
21
|
|
|
|
|
22
|
|
|
$db->createCommand()->renameTable('type', 'type_test'); |
|
23
|
|
|
$noCacheTable = $schema->getTableSchema('type', true); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertNotSame($noCacheTable, $cachedTable); |
|
26
|
|
|
|
|
27
|
|
|
$db->createCommand()->renameTable('type_test', 'type'); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @depends testSchemaCache |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testRefreshTableSchema(): void |
|
34
|
|
|
{ |
|
35
|
|
|
$db = $this->getConnection(); |
|
36
|
|
|
|
|
37
|
|
|
$schema = $db->getSchema(); |
|
38
|
|
|
$schema->schemaCacheEnable(true); |
|
39
|
|
|
$noCacheTable = $schema->getTableSchema('type', true); |
|
40
|
|
|
$schema->refreshTableSchema('type'); |
|
41
|
|
|
$refreshedTable = $schema->getTableSchema('type', false); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertNotSame($noCacheTable, $refreshedTable); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.