Failed Conditions
Pull Request — master (#74)
by Timon
04:03 queued 01:17
created

IndexTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 42
dl 0
loc 83
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testIndexList() 0 16 1
A testIndexDrop() 0 15 1
A testIndexRename() 0 22 1
A testIndexCreate() 0 10 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Operation;
5
6
use TBolier\RethinkQL\Response\ResponseInterface;
7
8
class IndexTest extends AbstractTableTest
9
{
10
    /**
11
     * @throws \Exception
12
     */
13
    public function testIndexCreate()
14
    {
15
        $this->insertDocument(1);
16
17
        $res = $this->r()
18
             ->table('tabletest')
19
             ->indexCreate('title')
20
             ->run();
21
22
        $this->assertObStatus(['created' => 1], $res->getData());
23
    }
24
25
    /**
26
     * @throws \Exception
27
     */
28
    public function testIndexDrop()
29
    {
30
        $this->insertDocument(1);
31
32
        $this->r()
33
             ->table('tabletest')
34
             ->indexCreate('title')
35
             ->run();
36
37
        $res = $this->r()
38
                    ->table('tabletest')
39
                    ->indexDrop('title')
40
                    ->run();
41
42
        $this->assertObStatus(['dropped' => 1], $res->getData());
43
    }
44
45
    /**
46
     * @throws \Exception
47
     */
48
    public function testIndexList()
49
    {
50
        $this->insertDocument(1);
51
52
        $this->r()
53
             ->table('tabletest')
54
             ->indexCreate('title')
55
             ->run();
56
57
        /** @var ResponseInterface $res */
58
        $res = $this->r()
59
                    ->table('tabletest')
60
                    ->indexList()
61
                    ->run();
62
63
        $this->assertEquals('title', $res->getData()[0]);
64
    }
65
66
    /**
67
     * @throws \Exception
68
     */
69
    public function testIndexRename()
70
    {
71
        $this->insertDocument(1);
72
73
        $this->r()
74
             ->table('tabletest')
75
             ->indexCreate('title')
76
             ->run();
77
78
        $res = $this->r()
79
                    ->table('tabletest')
80
                    ->indexRename('title', 'description')
81
                    ->run();
82
83
        $this->assertObStatus(['renamed' => 1], $res->getData());
84
85
        $res = $this->r()
86
                    ->table('tabletest')
87
                    ->indexList()
88
                    ->run();
89
90
        $this->assertEquals('description', $res->getData()[0]);
91
    }
92
}
93