Test Failed
Pull Request — master (#34)
by Timon
06:34
created

AvgTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 65
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAvg() 0 15 2
A testFilterAndAvg() 0 16 2
A testGetAllAndAvg() 0 16 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Aggregation;
5
6
use TBolier\RethinkQL\IntegrationTest\Query\AbstractTableTest;
7
use TBolier\RethinkQL\Response\ResponseInterface;
8
9
class AvgTest extends AbstractTableTest
10
{
11
    /**
12
     * @return void
13
     * @throws \Exception
14
     */
15
    public function testAvg(): void
16
    {
17
        $this->insertDocument(5);
18
        $this->insertDocument(4);
19
        $this->insertDocument(3);
20
        $this->insertDocument(2);
21
        $this->insertDocument(1);
22
23
        /** @var ResponseInterface $res */
24
        $res = $this->r()
25
            ->table('tabletest')
26
            ->avg('number')
27
            ->run();
28
29
        $this->assertTrue(is_float($res->getData()) || is_int($res->getData()));
30
    }
31
32
    /**
33
     * @return void
34
     * @throws \Exception
35
     */
36
    public function testFilterAndAvg(): void
37
    {
38
        $this->insertDocument(5);
39
        $this->insertDocument(4);
40
        $this->insertDocument(3);
41
        $this->insertDocument(2);
42
        $this->insertDocument(1);
43
44
        /** @var ResponseInterface $res */
45
        $res = $this->r()
46
                    ->table('tabletest')
47
                    ->filter(['description' => 'A document description.'])
48
                    ->avg('number')
49
                    ->run();
50
51
        $this->assertTrue(is_float($res->getData()) || is_int($res->getData()));
52
    }
53
54
    /**
55
     * @return void
56
     * @throws \Exception
57
     */
58
    public function testGetAllAndAvg(): void
59
    {
60
        $this->insertDocument(5);
61
        $this->insertDocument(4);
62
        $this->insertDocument(3);
63
        $this->insertDocument(2);
64
        $this->insertDocument(1);
65
66
        /** @var ResponseInterface $res */
67
        $res = $this->r()
68
                    ->table('tabletest')
69
                    ->getAll(1, 2, 3, 4, 5)
70
                    ->avg('number')
71
                    ->run();
72
73
        $this->assertTrue(is_float($res->getData()) || is_int($res->getData()));
74
    }
75
}
76