1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kint\Test\Object\Representation; |
4
|
|
|
|
5
|
|
|
use Kint\Object\Representation\SourceRepresentation; |
6
|
|
|
use Kint\Test\KintTestCase; |
7
|
|
|
|
8
|
|
|
class SourceRepresentationTest extends KintTestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @covers \Kint\Object\Representation\SourceRepresentation::__construct |
12
|
|
|
* @covers \Kint\Object\Representation\SourceRepresentation::getSource |
13
|
|
|
*/ |
14
|
|
|
public function testConstruct() |
15
|
|
|
{ |
16
|
|
|
$source = file_get_contents(__FILE__); |
17
|
|
|
$source = explode("\n", $source); |
18
|
|
|
$source = array_merge(array(null), $source); |
19
|
|
|
|
20
|
|
|
$r = new SourceRepresentation(__FILE__, 1); |
|
|
|
|
21
|
|
|
$this->assertSame('source', $r->getName()); |
22
|
|
|
$this->assertSame(array_slice($source, 1, 8, true), $r->source); |
23
|
|
|
|
24
|
|
|
$r = new SourceRepresentation(__FILE__, 1, 7); |
25
|
|
|
$this->assertSame(array_slice($source, 1, 8, true), $r->source); |
26
|
|
|
|
27
|
|
|
$r = new SourceRepresentation(__FILE__, 1, 9); |
28
|
|
|
$this->assertSame(array_slice($source, 1, 10, true), $r->source); |
29
|
|
|
$this->assertSame(implode("\n", array_slice($source, 1, 10, true)), $r->contents); |
30
|
|
|
|
31
|
|
|
// Trims the whitespace line in contents |
32
|
|
|
$r = new SourceRepresentation(__FILE__, 1, 6); |
33
|
|
|
$this->assertSame(array_slice($source, 1, 7, true), $r->source); |
34
|
|
|
$this->assertSame(implode("\n", array_slice($source, 1, 7, true)), $r->contents); |
35
|
|
|
|
36
|
|
|
$r = new SourceRepresentation(__FILE__.'/nonexistant', 1); |
37
|
|
|
$this->assertNull($r->source); |
38
|
|
|
$this->assertEmpty($r->contents); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
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.