Test Setup Failed
Push — next ( 738e04...b06172 )
by Jonathan
25:05
created

SourceRepresentationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testConstruct() 0 26 1
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