Completed
Push — next ( 3fc9f0...5d2fc6 )
by Jonathan
9s
created

RepresentationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 54
rs 10
c 1
b 0
f 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetLabel() 0 10 1
A testLabelIsImplicit() 0 7 1
A testConstruct() 0 14 1
A testSetName() 0 17 1
1
<?php
2
3
namespace Kint\Test\Object\Representation;
4
5
use Kint\Object\Representation\Representation;
6
use Kint\Test\KintTestCase;
7
8
class RepresentationTest extends KintTestCase
9
{
10
    public function testConstruct()
11
    {
12
        $r = new Representation('This is a label');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
13
        $this->assertEquals('This is a label', $r->label);
14
        $this->assertEquals('this_is_a_label', $r->getName());
15
16
        $r = new Representation('This is a label', 'this_is_a_name');
17
        $this->assertEquals('This is a label', $r->label);
18
        $this->assertEquals('this_is_a_name', $r->getName());
19
20
        $r = new Representation('Test # 3');
21
        $this->assertEquals('Test # 3', $r->label);
22
        $this->assertEquals('test_3', $r->getName());
23
    }
24
25
    public function testGetLabel()
26
    {
27
        $r = new Representation('This is a label');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
28
        $this->assertEquals('This is a label', $r->getLabel());
29
        $r->contents = array(1);
30
        $this->assertEquals('This is a label', $r->getLabel());
31
        $r->contents[] = 2;
32
        $r->contents[] = 3;
33
        $this->assertEquals('This is a label (3)', $r->getLabel());
34
    }
35
36
    public function testSetName()
37
    {
38
        $r = new Representation('Test');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
39
        $this->assertEquals('test', $r->getName());
40
41
        $r->setName('Test this string!');
42
        $this->assertEquals('test_this_string_', $r->getName());
43
44
        $r->setName('UPPERCASE HOLDS NO POWER HERE');
45
        $this->assertEquals('uppercase_holds_no_power_here', $r->getName());
46
47
        $r->setName('Multiple ! # () @!$#%@#$% special characters');
48
        $this->assertEquals('multiple_special_characters', $r->getName());
49
50
        $r->setName('But numbers work like 123');
51
        $this->assertEquals('but_numbers_work_like_123', $r->getName());
52
    }
53
54
    public function testLabelIsImplicit()
55
    {
56
        $r = new Representation('This is a label');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
57
        $this->assertEquals(false, $r->labelIsImplicit());
58
        $r->implicit_label = true;
59
        $this->assertEquals(true, $r->labelIsImplicit());
60
    }
61
}
62