Passed
Pull Request — master (#372)
by Wilmer
03:17 queued 44s
created

AbstractSchemaCache::testSchemaCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 9.9332
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);
0 ignored issues
show
Bug introduced by
The method getConnection() does not exist on Yiisoft\Db\Tests\AbstractSchemaCache. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
        /** @scrutinizer ignore-call */ 
14
        $db = $this->getConnection(true);

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.

Loading history...
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