Passed
Push — master ( 6b91b6...1f7653 )
by William
07:14
created

ExplainStatementTest::testBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 63
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 42
nc 1
nop 0
dl 0
loc 63
rs 9.248
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Tests\Builder;
6
7
use PhpMyAdmin\SqlParser\Parser;
8
use PhpMyAdmin\SqlParser\Tests\TestCase;
9
10
class ExplainStatementTest extends TestCase
11
{
12
    public function testBuilder(): void
13
    {
14
        /* Assertion 1 */
15
        $query = 'EXPLAIN SELECT * FROM test;';
16
        $parser = new Parser($query);
17
        $stmt = $parser->statements[0];
18
        $this->assertEquals(
19
            'EXPLAIN SELECT * FROM test',
20
            $stmt->build()
21
        );
22
23
        /* Assertion 2 */
24
        $query = 'EXPLAIN ANALYZE SELECT * FROM tablename;';
25
        $parser = new Parser($query);
26
        $stmt = $parser->statements[0];
27
        $this->assertEquals(
28
            'EXPLAIN ANALYZE SELECT * FROM tablename',
29
            $stmt->build()
30
        );
31
32
        /* Assertion 3 */
33
        $query = 'DESC ANALYZE SELECT * FROM tablename;';
34
        $parser = new Parser($query);
35
        $stmt = $parser->statements[0];
36
        $this->assertEquals(
37
            'DESC ANALYZE SELECT * FROM tablename',
38
            $stmt->build()
39
        );
40
41
        /* Assertion 4 */
42
        $query = 'ANALYZE SELECT * FROM tablename;';
43
        $parser = new Parser($query);
44
        $stmt = $parser->statements[0];
45
        $this->assertEquals(
46
            'ANALYZE SELECT * FROM tablename',
47
            $stmt->build()
48
        );
49
50
        /* Assertion 5 */
51
        $query = 'DESCRIBE tablename;';
52
        $parser = new Parser($query);
53
        $stmt = $parser->statements[0];
54
        $this->assertEquals(
55
            'DESCRIBE tablename',
56
            $stmt->build()
57
        );
58
59
        /* Assertion 6 */
60
        $query = 'DESC FOR CONNECTION 458';
61
        $parser = new Parser($query);
62
        $stmt = $parser->statements[0];
63
        $this->assertEquals(
64
            'DESC FOR CONNECTION 458',
65
            $stmt->build()
66
        );
67
68
        /* Assertion 6 */
69
        $query = 'EXPLAIN FORMAT=TREE SELECT * FROM db;';
70
        $parser = new Parser($query);
71
        $stmt = $parser->statements[0];
72
        $this->assertEquals(
73
            'EXPLAIN FORMAT=TREE SELECT * FROM db',
74
            $stmt->build()
75
        );
76
    }
77
}
78