1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace TBolier\RethinkQL\IntegrationTest\Query; |
5
|
|
|
|
6
|
|
|
use TBolier\RethinkQL\Response\Cursor; |
7
|
|
|
use TBolier\RethinkQL\Response\ResponseInterface; |
8
|
|
|
|
9
|
|
|
class GetAllTest extends AbstractTableTest |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @return void |
13
|
|
|
* @throws \Exception |
14
|
|
|
*/ |
15
|
|
|
public function testGetAll(): void |
16
|
|
|
{ |
17
|
|
|
$this->insertDocument(1); |
18
|
|
|
$this->insertDocument('stringId'); |
19
|
|
|
|
20
|
|
|
/** @var Cursor $cursor */ |
21
|
|
|
$cursor = $this->r() |
22
|
|
|
->table('tabletest') |
23
|
|
|
->getAll(1, 'stringId') |
24
|
|
|
->run(); |
25
|
|
|
|
26
|
|
|
/** @var array $array */ |
27
|
|
|
$array = $cursor->current(); |
28
|
|
|
|
29
|
|
|
$this->assertArraySubset(['description' => 'A document description.'], $array); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return void |
34
|
|
|
* @throws \Exception |
35
|
|
|
*/ |
36
|
|
|
public function testGetAllAndCount(): void |
37
|
|
|
{ |
38
|
|
|
$this->insertDocument(1); |
39
|
|
|
$this->insertDocument('stringId'); |
40
|
|
|
|
41
|
|
|
/** @var ResponseInterface $res */ |
42
|
|
|
$res = $this->r() |
43
|
|
|
->table('tabletest') |
44
|
|
|
->getAll(1, 'stringId') |
45
|
|
|
->count() |
46
|
|
|
->run(); |
47
|
|
|
|
48
|
|
|
$this->assertEquals(2, $res->getData()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return void |
53
|
|
|
* @throws \Exception |
54
|
|
|
*/ |
55
|
|
|
public function testGetAllAndSum(): void |
56
|
|
|
{ |
57
|
|
|
$this->insertDocument(1); |
58
|
|
|
$this->insertDocument('stringId'); |
59
|
|
|
|
60
|
|
|
/** @var ResponseInterface $res */ |
61
|
|
|
$res = $this->r() |
62
|
|
|
->table('tabletest') |
63
|
|
|
->getAll(1, 'stringId') |
64
|
|
|
->sum('number') |
65
|
|
|
->run(); |
66
|
|
|
|
67
|
|
|
$this->assertInternalType('int', $res->getData()); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// /** |
71
|
|
|
// * @return void |
72
|
|
|
// * @throws \Exception |
73
|
|
|
// */ |
74
|
|
|
// public function testGetAllAndIsEmpty(): void |
75
|
|
|
// { |
76
|
|
|
// $this->insertDocument(1); |
77
|
|
|
// $this->insertDocument('stringId'); |
78
|
|
|
// |
79
|
|
|
// /** @var ResponseInterface $res */ |
80
|
|
|
// $res = $this->r() |
81
|
|
|
// ->table('tabletest') |
82
|
|
|
// ->getAll(1, 'stringId') |
83
|
|
|
// ->isEmpty() |
84
|
|
|
// ->run(); |
85
|
|
|
// |
86
|
|
|
// $this->assertFalse($res->getData()); |
87
|
|
|
// } |
88
|
|
|
} |
89
|
|
|
|