Completed
Pull Request — master (#3)
by Harry
05:31
created

testEmptyFileWillReturnEmptyArrayForGetContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Test\Integration\Node;
15
16
use Graze\DataFile\Modify\Exception\CopyFailedException;
17
use Graze\DataFile\Node\FileNode;
18
use Graze\DataFile\Test\TestCase;
19
use League\Flysystem\FilesystemInterface;
20
use Mockery as m;
21
22
class FileNodeTest extends TestCase
23
{
24
    public function testEmptyFileWillReturnEmptyArrayForGetContents()
25
    {
26
        $fileSystem = m::mock(FilesystemInterface::class);
27
        $file = new FileNode($fileSystem, 'not/exists');
28
29
        $fileSystem->shouldReceive('has')
30
                   ->with('not/exists')
31
                   ->andReturn(false);
32
33
        static::assertEquals([], $file->getContents());
34
    }
35
36
    public function testWhenCopyFailsItRaisesAnException()
37
    {
38
        $fileSystem = m::mock(FilesystemInterface::class);
39
        $localFile = new FileNode($fileSystem, 'some/random');
40
41
        $newPath = new FileNode($fileSystem, 'some/target');
42
43
        $fileSystem->shouldReceive('copy')
44
                   ->with($localFile->getPath(), $newPath->getPath())
45
                   ->andReturn(false);
46
47
        $this->expectException(CopyFailedException::class);
48
49
        $localFile->copy($newPath->getPath());
50
    }
51
}
52