Completed
Push — master ( 522585...279d2c )
by Harry
04:14
created

FileNodeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyFileWillReturnEmptyArrayForGetContents() 0 11 1
A testWhenCopyFailsItRaisesAnException() 0 15 1
1
<?php
2
3
namespace Graze\DataFile\Test\Integration\Node;
4
5
use Graze\DataFile\Modify\Exception\CopyFailedException;
6
use Graze\DataFile\Modify\MakeDirectory;
7
use Graze\DataFile\Node\FileNode;
8
use Graze\DataFile\Test\TestCase;
9
use League\Flysystem\FilesystemInterface;
10
use Mockery as m;
11
12
class FileNodeTest extends TestCase
13
{
14
    public function testEmptyFileWillReturnEmptyArrayForGetContents()
15
    {
16
        $fileSystem = m::mock(FilesystemInterface::class);
17
        $file = new FileNode($fileSystem, 'not/exists');
18
19
        $fileSystem->shouldReceive('has')
20
                   ->with('not/exists')
21
                   ->andReturn(false);
22
23
        static::assertEquals([], $file->getContents());
24
    }
25
26
    public function testWhenCopyFailsItRaisesAnException()
27
    {
28
        $fileSystem = m::mock(FilesystemInterface::class);
29
        $localFile = new FileNode($fileSystem, 'some/random');
30
31
        $newPath = new FileNode($fileSystem, 'some/target');
32
33
        $fileSystem->shouldReceive('copy')
34
            ->with($localFile->getPath(), $newPath->getPath())
35
            ->andReturn(false);
36
37
        $this->expectException(CopyFailedException::class);
38
39
        $localFile->copy($newPath->getPath());
40
    }
41
}
42