Passed
Push — master ( 8cb90e...59fa3d )
by Timon
08:19 queued 05:53
created

BetweenTest::testBetweenNoResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
use TBolier\RethinkQL\Types\Term\TermType;
9
10
class BetweenTest extends AbstractTableTest
11
{
12
    /**
13
     * @throws \Exception
14
     */
15
    public function testBetweenMin()
16
    {
17
        $this->insertDocument(1);
18
        $this->insertDocument(3);
19
20
        /** @var Cursor $cursor */
21
        $cursor = $this->r()
22
            ->table('tabletest')
23
            ->between(1, 2)
24
            ->run();
25
26
        /** @var array $array */
27
        $array = $cursor->current();
28
29
        $this->assertInstanceOf(\Iterator::class, $cursor);
30
        $this->assertEquals(1, $cursor->count());
31
        $this->assertArraySubset(['title' => 'Test document 1'], $array);
32
    }
33
34
    /**
35
     * @throws \Exception
36
     */
37
    public function testBetweenMax()
38
    {
39
        $this->insertDocument(1);
40
        $this->insertDocument(3);
41
42
        /** @var Cursor $cursor */
43
        $cursor = $this->r()
44
            ->table('tabletest')
45
            ->between(2, 3)
46
            ->run();
47
48
        $this->assertInstanceOf(\Iterator::class, $cursor);
49
        $this->assertCount(0, $cursor);
50
    }
51
52
    /**
53
     * @throws \Exception
54
     */
55
    public function testBetweenMultiple()
56
    {
57
        $this->insertDocument(1);
58
        $this->insertDocument(2);
59
        $this->insertDocument(3);
60
        $this->insertDocument(4);
61
        $this->insertDocument(5);
62
63
        /** @var Cursor $cursor */
64
        $cursor = $this->r()
65
            ->table('tabletest')
66
            ->between(2, 4)
67
            ->run();
68
69
        $this->assertInstanceOf(\Iterator::class, $cursor);
70
        $this->assertCount(2, $cursor);
71
    }
72
73
    /**
74
     * @return void
75
     * @throws \Exception
76
     */
77
    public function testBetweenNoResult(): void
78
    {
79
        $this->insertDocument('stringId');
80
81
        /** @var Cursor $cursor */
82
        $cursor = $this->r()
83
            ->table('tabletest')
84
            ->between(2, 4)
85
            ->run();
86
87
        $this->assertInstanceOf(\Iterator::class, $cursor);
88
        $this->assertCount(0, $cursor);
89
    }
90
}
91