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

SpaceIndexCachingTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 14
dl 0
loc 25
rs 10
c 2
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCacheIndex() 0 10 1
A testFlushIndexes() 0 11 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