Passed
Push — master ( 2f6a1e...868687 )
by Timon
04:41
created

CursorTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Query;
5
6
use TBolier\RethinkQL\Response\ResponseInterface;
7
8
class CursorTest extends AbstractTableTest
9
{
10
    /**
11
     * @throws \Exception
12
     */
13
    public function testCursor()
14
    {
15
        $this->insertDocuments();
16
17
        $response = $this->r()
18
            ->table('tabletest')
19
            ->count()
20
            ->run();
21
22
        $this->assertEquals(1000, $response->getData());
23
    }
24
25
    /**
26
     * @return ResponseInterface
27
     * @throws \Exception
28
     */
29
    private function insertDocuments(): ResponseInterface
30
    {
31
        $documents = [];
32
33
        for ($i = 1; $i <= 1000; $i++) {
34
            $documents[] = [
35
                'id' => $i,
36
                'title' => 'Test document',
37
                'description' => 'My first document.',
38
            ];
39
        }
40
41
        /** @var ResponseInterface $res */
42
        $res = $this->r()
43
            ->table('tabletest')
44
            ->insert($documents)
45
            ->run();
46
47
        $this->assertEquals(1000, $res->getData()['inserted']);
48
49
        return $res;
50
    }
51
}
52