TextFileTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testOpenNonExisting() 0 12 1
A testOpenExisting() 0 12 1
1
<?php
2
3
namespace TextFile\Tests;
4
5
use TextFile\TextFile;
6
7
/**
8
 * Class TextFileTest
9
 *
10
 * @package TextFile\Tests
11
 */
12
class TextFileTest extends TextFileTestCase
13
{
14
    /**
15
     * @covers TextFile\TextFile::open
16
     * @covers TextFile\TextFile::__construct
17
     * @covers TextFile\TextFile::getSplFileObject
18
     */
19
    public function testOpenNonExisting()
20
    {
21
        $filePath = $this->workspace . DIRECTORY_SEPARATOR . mt_rand(0, 1000) . '.txt';
22
23
        $this->assertFalse($this->filesystem->exists($filePath));
24
25
        $textFile = new TextFile($filePath);
26
27
        $this->assertTrue($this->filesystem->exists($filePath));
28
        $this->assertInstanceOf('\SplFileObject', $textFile->getSplFileObject());
29
        $this->assertSame($filePath, $textFile->getSplFileObject()->getRealPath());
30
    }
31
32
    /**
33
     * @covers TextFile\TextFile::open
34
     * @covers TextFile\TextFile::__construct
35
     * @covers TextFile\TextFile::getSplFileObject
36
     */
37
    public function testOpenExisting()
38
    {
39
        $filePath = $this->createTestFileFromFixtures('simple_multiline_file.txt');
40
41
        $this->assertTrue($this->filesystem->exists($filePath));
42
43
        $textFile = new TextFile($filePath);
44
45
        $this->assertTrue($this->filesystem->exists($filePath));
46
        $this->assertInstanceOf('\SplFileObject', $textFile->getSplFileObject());
47
        $this->assertSame($filePath, $textFile->getSplFileObject()->getRealPath());
48
    }
49
}
50