Test Failed
Pull Request — master (#28)
by Timon
03:33 queued 15s
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
class FilterTest extends AbstractTableTest
7
{
8
    /**
9
     * @throws \Exception
10
     */
11
    public function testFilter()
12
    {
13
        $this->insertDocument(1);
14
15
        /** @var \Iterable $cursor */
16
        $cursor = $this->r()
17
            ->table('tabletest')
18
            ->filter(['title' => 'Test document 1'])
19
            ->run();
20
21
        $this->assertInstanceOf(\Iterator::class, $cursor);
22
        $this->assertInternalType('array', $cursor->current());
0 ignored issues
show
Bug introduced by
The method current() does not exist on iterable. It seems like you code against a sub-type of iterable such as IntlCodePointBreakIterator or IntlRuleBasedBreakIterator or Iterator or IntlBreakIterator or MongoGridFSCursor or Mockery\Generator\TestTraversableInterface2 or SimpleXMLIterator. ( Ignorable by Annotation )

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

22
        $this->assertInternalType('array', $cursor->/** @scrutinizer ignore-call */ current());
Loading history...
23
    }
24
25
    /**
26
     * @throws \Exception
27
     */
28
    public function testFilterOnMultipleDocuments()
29
    {
30
        $this->insertDocument(1);
31
        $this->insertDocument(2);
32
        $this->insertDocument(3);
33
        $this->insertDocument(4);
34
        $this->insertDocument(5);
35
36
        /** @var \Iterable $cursor */
37
        $cursor = $this->r()
38
            ->table('tabletest')
39
            ->filter(['title' => 'Test document 1'])
40
            ->run();
41
42
        $this->assertEquals(1, \count($cursor));
0 ignored issues
show
Bug introduced by
$cursor of type Iterable is incompatible with the type Countable|array expected by parameter $var of count(). ( Ignorable by Annotation )

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

42
        $this->assertEquals(1, \count(/** @scrutinizer ignore-type */ $cursor));
Loading history...
43
    }
44
}
45