Passed
Pull Request — master (#63)
by Eugene
05:16
created

ClientSpaceCachingTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCacheSpace() 0 9 1
A testFlushSpaces() 0 10 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
18
/**
19
 * @eval create_space('test_space_caching'):create_index('primary', {type = 'tree', parts = {1, 'unsigned'}})
20
 */
21
final class ClientSpaceCachingTest extends TestCase
22
{
23
    public function testCacheSpace() : void
24
    {
25
        $total = self::getTotalCalls(self::STAT_REQUEST_SELECT);
26
27
        $this->client->flushSpaces();
28
        $this->client->getSpace('test_space_caching')->select(Criteria::key([]));
29
        $this->client->getSpace('test_space_caching')->select(Criteria::key([]));
30
31
        self::assertSame(3, self::getTotalCalls(self::STAT_REQUEST_SELECT) - $total);
32
    }
33
34
    public function testFlushSpaces() : void
35
    {
36
        $total = self::getTotalCalls(self::STAT_REQUEST_SELECT);
37
38
        $this->client->flushSpaces();
39
        $this->client->getSpace('test_space_caching')->select(Criteria::key([]));
40
        $this->client->flushSpaces();
41
        $this->client->getSpace('test_space_caching')->select(Criteria::key([]));
42
43
        self::assertSame(4, self::getTotalCalls(self::STAT_REQUEST_SELECT) - $total);
44
    }
45
}
46