DirectoryTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 102
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCreate() 0 16 1
A testRemove() 0 16 1
A testClear() 0 16 1
1
<?php
2
namespace Redaxscript\Tests\Filesystem;
3
4
use org\bovigo\vfs\vfsStream as Stream;
5
use Redaxscript\Filesystem;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * DirectoryTest
10
 *
11
 * @since 3.2.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Filesystem\Directory
18
 */
19
20
class DirectoryTest extends TestCaseAbstract
21
{
22
	/**
23
	 * setUp
24
	 *
25
	 * @since 3.2.0
26
	 */
27
28
	public function setUp() : void
29
	{
30
		Stream::setup('root', 0777, $this->getJSON('tests' . DIRECTORY_SEPARATOR. 'unit-provider' . DIRECTORY_SEPARATOR. 'Filesystem' . DIRECTORY_SEPARATOR. 'FilesystemTest_setUp.json'));
31
	}
32
33
	/**
34
	 * testCreate
35
	 *
36
	 * @since 3.2.0
37
	 *
38
	 * @param string $root
39
	 * @param bool $recursive
40
	 * @param string $directory
41
	 * @param array $expectArray
42
	 *
43
	 * @dataProvider providerAutoloader
44
	 */
45
46
	public function testCreate(string $root = null, bool $recursive = null, string $directory = null, array $expectArray = []) : void
47
	{
48
		/* setup */
49
50
		$filesystem = new Filesystem\Directory();
51
		$filesystem->init(Stream::url($root), $recursive);
52
		$filesystem->createDirectory($directory);
53
54
		/* actual */
55
56
		$actualArray = $filesystem->getArray();
57
58
		/* compare */
59
60
		$this->assertEquals($expectArray, $actualArray);
61
	}
62
63
	/**
64
	 * testRemove
65
	 *
66
	 * @since 3.2.0
67
	 *
68
	 * @param string $root
69
	 * @param bool $recursive
70
	 * @param string $directory
71
	 * @param array $expectArray
72
	 *
73
	 * @dataProvider providerAutoloader
74
	 */
75
76
	public function testRemove(string $root = null, bool $recursive = null, string $directory = null, array $expectArray = []) : void
77
	{
78
		/* setup */
79
80
		$filesystem = new Filesystem\Directory();
81
		$filesystem->init(Stream::url($root), $recursive);
82
		$filesystem->removeDirectory($directory);
83
84
		/* actual */
85
86
		$actualArray = $filesystem->getArray();
87
88
		/* compare */
89
90
		$this->assertEquals($expectArray, $actualArray);
91
	}
92
93
	/**
94
	 * testClear
95
	 *
96
	 * @since 3.2.0
97
	 *
98
	 * @param string $root
99
	 * @param bool $recursive
100
	 * @param array $expectArray
101
	 *
102
	 * @dataProvider providerAutoloader
103
	 */
104
105
	public function testClear(string $root = null, bool $recursive = null, array $expectArray = []) : void
106
	{
107
		/* setup */
108
109
		$filesystem = new Filesystem\Directory();
110
		$filesystem->init(Stream::url($root), $recursive);
111
		$filesystem->clearDirectory();
112
113
		/* actual */
114
115
		$actualArray = $filesystem->getArray();
116
117
		/* compare */
118
119
		$this->assertEquals($expectArray, $actualArray);
120
	}
121
}
122