BetweenTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 37
dl 0
loc 79
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testBetweenMax() 0 13 1
A testBetweenMultiple() 0 16 1
A testBetweenNoResult() 0 12 1
A testBetweenMin() 0 17 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Operation;
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);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

31
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset(['title' => 'Test document 1'], $array);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
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