Passed
Push — master ( e0d17a...139da0 )
by Michel
03:37
created

LimitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testLimitWithMultipleTransformations() 0 18 1
A testLimit() 0 15 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Transformation;
5
6
use TBolier\RethinkQL\IntegrationTest\Query\AbstractTableTest;
7
use TBolier\RethinkQL\Response\Cursor;
8
use TBolier\RethinkQL\Response\ResponseInterface;
9
10
class LimitTest extends AbstractTableTest
11
{
12
    /**
13
     * @return void
14
     * @throws \Exception
15
     */
16
    public function testLimit(): void
17
    {
18
        $this->insertDocument(1);
19
        $this->insertDocument(2);
20
        $this->insertDocument(3);
21
        $this->insertDocument(4);
22
        $this->insertDocument(5);
23
24
        /** @var Cursor $cursor */
25
        $cursor = $this->r()
26
            ->table('tabletest')
27
            ->limit(2)
28
            ->run();
29
30
        $this->assertCount(2, $cursor);
31
    }
32
33
    public function testLimitWithMultipleTransformations(): void
34
    {
35
        $this->insertDocument(1);
36
        $this->insertDocument(2);
37
        $this->insertDocument(3);
38
        $this->insertDocument(4);
39
        $this->insertDocument(5);
40
41
        /** @var ResponseInterface $cursor */
42
        $response = $this->r()
43
            ->table('tabletest')
44
            ->filter(['description' => 'A document description.'])
45
            ->orderBy($this->r()->desc('id'))
46
            ->skip(1)
47
            ->limit(2)
48
            ->run();
49
50
        $this->assertCount(2, $response->getData());
1 ignored issue
show
Bug introduced by
It seems like $response->getData() can also be of type string; however, parameter $haystack of PHPUnit\Framework\Assert::assertCount() does only seem to accept Countable|iterable, maybe add an additional type check? ( Ignorable by Annotation )

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

50
        $this->assertCount(2, /** @scrutinizer ignore-type */ $response->getData());
Loading history...
51
    }
52
}
53