|
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'); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
57
|
|
|
$this->assertEquals(false, $r->labelIsImplicit()); |
|
58
|
|
|
$r->implicit_label = true; |
|
59
|
|
|
$this->assertEquals(true, $r->labelIsImplicit()); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
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.