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

CountTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 57
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFilterCount() 0 16 1
A testCount() 0 10 1
A testFilterCountOnMultipleDocuments() 0 16 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Query;
5
6
use TBolier\RethinkQL\IntegrationTest\Query\AbstractTableTest;
7
use TBolier\RethinkQL\Response\ResponseInterface;
8
9
class CountTest extends AbstractTableTest
10
{
11
    /**
12
     * @throws \Exception
13
     */
14
    public function testCount()
15
    {
16
        $this->insertDocument(1);
17
18
        $res = $this->r()
19
            ->table('tabletest')
20
            ->count()
21
            ->run();
22
23
        $this->assertInternalType('int', $res->getData());
24
    }
25
26
    /**
27
     * @throws \Exception
28
     */
29
    public function testFilterCount()
30
    {
31
        $this->insertDocument(1);
32
        $this->insertDocument(2);
33
        $this->insertDocument(3);
34
        $this->insertDocument(4);
35
        $this->insertDocument(5);
36
37
        /** @var ResponseInterface $res */
38
        $res = $this->r()
39
            ->table('tabletest')
40
            ->filter(['id' => 1])
41
            ->count()
42
            ->run();
43
44
        $this->assertEquals(1, $res->getData());
45
    }
46
47
    /**
48
     * @throws \Exception
49
     */
50
    public function testFilterCountOnMultipleDocuments()
51
    {
52
        $this->insertDocument(1);
53
        $this->insertDocument(2);
54
        $this->insertDocument(3);
55
        $this->insertDocument(4);
56
        $this->insertDocument(5);
57
58
        /** @var ResponseInterface $res */
59
        $res = $this->r()
60
            ->table('tabletest')
61
            ->filter(['description' => 'A document description.'])
62
            ->count()
63
            ->run();
64
65
        $this->assertEquals(5, $res->getData());
66
    }
67
}
68