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

FilterTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFilter() 0 12 1
A testFilterOnMultipleDocuments() 0 15 1
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