Passed
Push — master ( 28768d...a4b5ac )
by Timon
02:33
created

IndexTest::testIndexCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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());
0 ignored issues
show
Bug introduced by
The method getData() does not exist on TBolier\RethinkQL\Response\Cursor. ( 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->assertObStatus(['created' => 1], $res->/** @scrutinizer ignore-call */ getData());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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