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

testWhenCopyFailsItRaisesAnException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
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