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\Exception\RequestFailed; |
17
|
|
|
use Tarantool\Client\Schema\Criteria; |
18
|
|
|
use Tarantool\Client\Schema\Operations; |
19
|
|
|
use Tarantool\Client\Tests\Integration\TestCase; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @lua space = create_space('request_upsert') |
23
|
|
|
* @lua space:create_index('primary', {type = 'hash', parts = {1, 'unsigned'}}) |
24
|
|
|
*/ |
25
|
|
|
final class UpsertTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
public function testUpsert() : void |
28
|
|
|
{ |
29
|
|
|
$space = $this->client->getSpace('request_upsert'); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$key = 10; |
32
|
|
|
$values = [$key, 'upserted']; |
33
|
|
|
$operations = Operations::splice(1, 0, 1, 'U'); |
34
|
|
|
$updatedValues = [$key, 'Upserted']; |
35
|
|
|
|
36
|
|
|
$space->upsert($values, $operations); |
37
|
|
|
self::assertSame([$values], $space->select(Criteria::key([$key]))); |
38
|
|
|
|
39
|
|
|
$space->upsert($values, $operations); |
40
|
|
|
self::assertSame([$updatedValues], $space->select(Criteria::key([$key]))); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testUpsertEmptyTuple() : void |
44
|
|
|
{ |
45
|
|
|
$space = $this->client->getSpace('request_upsert'); |
46
|
|
|
|
47
|
|
|
$this->expectException(RequestFailed::class); |
48
|
|
|
$this->expectExceptionCode(39); // ER_FIELD_MISSING |
49
|
|
|
|
50
|
|
|
$space->upsert([], Operations::set(1, 'Foo')); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.