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

FilterTest::testFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
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
8
class FilterTest extends AbstractTableTest
9
{
10
    /**
11
     * @throws \Exception
12
     */
13
    public function testFilter()
14
    {
15
        $this->insertDocument(1);
16
17
        /** @var Cursor $cursor */
18
        $cursor = $this->r()
19
            ->table('tabletest')
20
            ->filter(['title' => 'Test document 1'])
21
            ->run();
22
23
        $this->assertInstanceOf(\Iterator::class, $cursor);
24
        $this->assertInternalType('array', $cursor->current());
25
    }
26
27
    /**
28
     * @throws \Exception
29
     */
30
    public function testFilterOnMultipleDocuments()
31
    {
32
        $this->insertDocument(1);
33
        $this->insertDocument(2);
34
        $this->insertDocument(3);
35
        $this->insertDocument(4);
36
        $this->insertDocument(5);
37
38
        /** @var Cursor $cursor */
39
        $cursor = $this->r()
40
            ->table('tabletest')
41
            ->filter(['title' => 'Test document 1'])
42
            ->run();
43
44
        $this->assertCount(1, $cursor);
45
    }
46
}
47