Passed
Pull Request — master (#63)
by Eugene
03:45
created

SpaceIndexCachingTest::testCacheIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 10
c 1
b 0
f 1
1
<?php
2
3
/**
4
 * This file is part of the Tarantool Client package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Tarantool\Client\Tests\Integration;
15
16
use Tarantool\Client\Schema\Criteria;
17
use Tarantool\Client\Schema\Space;
18
19
final class SpaceIndexCachingTest extends TestCase
20
{
21
    public function testCacheIndex() : void
22
    {
23
        $space = $this->client->getSpaceById(Space::VINDEX_ID);
24
        $total = self::getTotalCalls(self::STAT_REQUEST_SELECT);
25
26
        $space->flushIndexes();
27
        $space->select(Criteria::index('name'));
28
        $space->select(Criteria::index('name'));
29
30
        self::assertSame(3, self::getTotalCalls(self::STAT_REQUEST_SELECT) - $total);
31
    }
32
33
    public function testFlushIndexes() : void
34
    {
35
        $space = $this->client->getSpaceById(Space::VINDEX_ID);
36
        $total = self::getTotalCalls(self::STAT_REQUEST_SELECT);
37
38
        $space->flushIndexes();
39
        $space->select(Criteria::index('name'));
40
        $space->flushIndexes();
41
        $space->select(Criteria::index('name'));
42
43
        self::assertSame(4, self::getTotalCalls(self::STAT_REQUEST_SELECT) - $total);
44
    }
45
}
46