Failed Conditions
Pull Request — master (#34)
by Marc
03:16
created

SkipTest::testFilterAndSkip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Aggregation;
5
6
use TBolier\RethinkQL\IntegrationTest\Query\AbstractTableTest;
7
use TBolier\RethinkQL\Response\Cursor;
8
use TBolier\RethinkQL\Response\ResponseInterface;
9
10
class SkipTest extends AbstractTableTest
11
{
12
    /**
13
     * @return void
14
     * @throws \Exception
15
     */
16
    public function testSkip(): void
17
    {
18
        $this->insertDocument(1);
19
        $this->insertDocument(2);
20
        $this->insertDocument(3);
21
        $this->insertDocument(4);
22
        $this->insertDocument(5);
23
24
        /** @var Cursor $cursor */
25
        $cursor = $this->r()
26
            ->table('tabletest')
27
            ->skip(2)
28
            ->run();
29
30
        $this->assertCount(3, $cursor);
31
    }
32
33
    /**
34
     * @return void
35
     * @throws \Exception
36
     */
37
    public function testFilterAndSkip(): void
38
    {
39
        $this->insertDocument(1);
40
        $this->insertDocument(2);
41
        $this->insertDocument(3);
42
        $this->insertDocument(4);
43
        $this->insertDocument(5);
44
45
        /** @var Cursor $cursor */
46
        $cursor = $this->r()
47
                       ->table('tabletest')
48
                       ->filter(['description' => 'A document description.'])
49
                       ->skip(2)
50
                       ->run();
51
52
        $this->assertCount(3, $cursor);
53
    }
54
55
    /**
56
     * @return void
57
     * @throws \Exception
58
     */
59
    public function testSkipAndOrderBy(): void
60
    {
61
        $this->insertDocument(1);
62
        $this->insertDocument(2);
63
        $this->insertDocument(3);
64
        $this->insertDocument(4);
65
        $this->insertDocument(5);
66
67
        /** @var ResponseInterface $res */
68
        $res = $this->r()
69
                       ->table('tabletest')
70
                       ->filter(['description' => 'A document description.'])
71
                       ->skip(2)
72
                       ->orderBy($this->r()->asc('id'))
73
                       ->run();
74
75
        $this->assertArraySubset(['id' => 1], $res->getData()[0]);
76
    }
77
}
78