Completed
Push — master ( 03e47f...db33ac )
by WEBEWEB
06:42 queued 01:35
created

DirectoryUtilityTest::testDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2017 NdC/WBW
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Tests\Utility;
13
14
use PHPUnit_Framework_TestCase;
15
use WBW\Library\Core\Utility\DirectoryUtility;
16
17
/**
18
 * Directory utility test.
19
 *
20
 * @author NdC/WBW <https://github.com/webeweb/>
21
 * @package WBW\Library\Core\Tests\Utility
22
 * @final
23
 */
24
final class DirectoryUtilityTest extends PHPUnit_Framework_TestCase {
25
26
	/**
27
	 * Tests the create() method.
28
	 *
29
	 * @return void
30
	 */
31
	public function testCreate() {
32
33
		$arg1	 = getcwd() . "/phpunit";
34
		$arg2	 = $arg1 . "/unittest";
35
36
		$this->assertEquals(true, DirectoryUtility::create($arg1));
37
		$this->assertEquals(null, DirectoryUtility::create($arg1));
38
		$this->assertEquals(true, DirectoryUtility::create($arg2));
39
	}
40
41
	/**
42
	 * Tests the isEmpty() method.
43
	 *
44
	 * @return void
45
	 * @depends testCreate
46
	 */
47
	public function testIsEmpty() {
48
49
		$arg1	 = getcwd() . "/phpunit";
50
		$arg2	 = $arg1 . "/unittest";
51
52
		$this->assertEquals(null, DirectoryUtility::isEmpty("exception"));
53
		$this->assertEquals(false, DirectoryUtility::isEmpty($arg1));
54
		$this->assertEquals(true, DirectoryUtility::isEmpty($arg2));
55
	}
56
57
	/**
58
	 * Tests the rename() method.
59
	 *
60
	 * @return void
61
	 * @depends testCreate
62
	 */
63
	public function testRename() {
64
65
		$arg1	 = getcwd() . "/phpunit";
66
		$arg2	 = $arg1 . "/unittest";
67
68
		$this->assertEquals(true, DirectoryUtility::rename($arg2, $arg2 . "2"));
69
		$this->assertEquals(null, DirectoryUtility::rename($arg2, $arg2 . "2"));
70
		$this->assertEquals(null, DirectoryUtility::rename($arg2 . "2", $arg1));
71
	}
72
73
	/**
74
	 * Tests the delete() method.
75
	 *
76
	 * @return void
77
	 * @depends testRename
78
	 */
79
	public function testDelete() {
80
81
		$arg1	 = getcwd() . "/phpunit";
82
		$arg2	 = $arg1 . "/unittest2";
83
84
		$this->assertEquals(null, DirectoryUtility::delete($arg1));
85
		$this->assertEquals(true, DirectoryUtility::delete($arg2));
86
		$this->assertEquals(true, DirectoryUtility::delete($arg1));
87
	}
88
89
}
90