Completed
Pull Request — master (#3)
by Harry
07:29
created

MakeDirectoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 68.09 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCanMakeDirectory() 11 11 1
A testCanMakeDirectoryWithSpecificUMode() 11 11 1
A testCanCallMakeDirectoryWithAnExistingFolder() 10 10 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\Integration\Modify;
15
16
use Graze\DataFile\Modify\MakeDirectory;
17
use Graze\DataFile\Node\LocalFile;
18
use Graze\DataFile\Test\AbstractFileTestCase;
19
use Mockery as m;
20
21
class MakeDirectoryTest extends AbstractFileTestCase
22
{
23
    /**
24
     * @var MakeDirectory
25
     */
26
    private $maker;
27
28
    public function setUp()
29
    {
30
        $this->maker = new MakeDirectory();
31
    }
32
33 View Code Duplication
    public function testCanMakeDirectory()
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...
34
    {
35
        $file = new LocalFile(static::$dir . 'test/file');
36
37
        static::assertFalse(file_exists($file->getDirectory()));
38
39
        $retFile = $this->maker->makeDirectory($file);
40
41
        static::assertTrue(file_exists($file->getDirectory()));
42
        static::assertSame($file, $retFile);
43
    }
44
45 View Code Duplication
    public function testCanMakeDirectoryWithSpecificUMode()
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...
46
    {
47
        $file = new LocalFile(static::$dir . 'umode_test/file');
48
49
        static::assertFalse(file_exists($file->getDirectory()));
50
51
        $retFile = $this->maker->makeDirectory($file, MakeDirectory::VISIBILITY_PUBLIC);
52
53
        static::assertEquals(0755, fileperms($file->getDirectory()) & 0777);
54
        static::assertSame($retFile, $file);
55
    }
56
57 View Code Duplication
    public function testCanCallMakeDirectoryWithAnExistingFolder()
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...
58
    {
59
        $file = new LocalFile(static::$dir . 'no_dir_file');
60
61
        static::assertTrue(file_exists($file->getDirectory()));
62
63
        $retFile = $this->maker->makeDirectory($file);
64
65
        static::assertSame($retFile, $file);
66
    }
67
}
68