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

UpsertTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testUpsert() 0 14 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\Requests;
15
16
use Tarantool\Client\Schema\Criteria;
17
use Tarantool\Client\Schema\Operations;
18
use Tarantool\Client\Tests\Integration\TestCase;
19
20
/**
21
 * @eval space = create_space('request_upsert')
22
 * @eval space:create_index('primary', {type = 'hash', parts = {1, 'unsigned'}})
23
 */
24
final class UpsertTest extends TestCase
25
{
26
    public function testUpsert() : void
27
    {
28
        $space = $this->client->getSpace('request_upsert');
29
30
        $key = 10;
31
        $values = [$key, 'upserted'];
32
        $operations = Operations::splice(1, 0, 1, 'U');
33
        $updatedValues = [$key, 'Upserted'];
34
35
        $space->upsert($values, $operations);
36
        self::assertSame([$values], $space->select(Criteria::key([$key])));
37
38
        $space->upsert($values, $operations);
39
        self::assertSame([$updatedValues], $space->select(Criteria::key([$key])));
40
    }
41
}
42