Completed
Pull Request — master (#3)
by Harry
03:17
created

MakeDirectoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 81.25 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 6
dl 13
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testWhenCreateDirReturnsFalseAnExceptionIsthrown() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Unit\Modify;
15
16
use Graze\DataFile\Modify\Exception\MakeDirectoryFailedException;
17
use Graze\DataFile\Modify\MakeDirectory;
18
use Graze\DataFile\Node\FileNode;
19
use Graze\DataFile\Test\TestCase;
20
use League\Flysystem\FilesystemInterface;
21
use Mockery as m;
22
23
class MakeDirectoryTest extends TestCase
24
{
25 View Code Duplication
    public function testWhenCreateDirReturnsFalseAnExceptionIsthrown()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        $fileSystem = m::mock(FilesystemInterface::class);
28
        $directory = new FileNode($fileSystem, 'random/path');
29
30
        $fileSystem->shouldReceive('createDir')
31
                   ->with($directory->getDirectory(), ['visibility' => 'public'])
32
                   ->andReturn(false);
33
        $this->expectException(MakedirectoryFailedException::class);
34
35
        $maker = new MakeDirectory();
36
        $maker->makeDirectory($directory);
37
    }
38
}
39