Test Setup Failed
Push — test ( b7242e...71734b )
by Jonathan
03:24
created

SourceRepresentationTest::testConstruct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 26
rs 8.8571
c 1
b 0
f 0
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);
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...
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