Passed
Push — master ( 66c616...00643e )
by Eugene
03:07
created

UpsertTest::testUpsert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.9666
c 2
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\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