Completed
Push — master ( cbd317...231b94 )
by Henry
09:43
created

tests/phpunit/Filesystem/DirectoryTest.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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()
29
	{
30
		Stream::setup('root', 0777, $this->getJSON('tests' . DIRECTORY_SEPARATOR. 'provider' . DIRECTORY_SEPARATOR. 'Filesystem' . DIRECTORY_SEPARATOR. 'FilesystemTest_setUp.json'));
0 ignored issues
show
It seems like $this->getJSON('tests' ....systemTest_setUp.json') targeting Redaxscript\Tests\TestCaseAbstract::getJSON() can also be of type null; however, org\bovigo\vfs\vfsStream::setup() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
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 = [])
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 = [])
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 = [])
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