Completed
Branch master (0d9475)
by WEBEWEB
02:41 queued 01:18
created

StringUtilityTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
rs 10
c 1
b 0
f 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\StringUtility;
16
17
/**
18
 * String utility test.
19
 *
20
 * @author NdC/WBW <https://github.com/webeweb/>
21
 * @package WBW\Library\Core\Tests\Utility
22
 * @final
23
 */
24
final class StringUtilityTest extends PHPUnit_Framework_TestCase {
25
26
	/**
27
	 * Tests the parseArray() method.
28
	 *
29
	 * @return void
30
	 */
31
	public function testParseArray() {
32
33
		$arg1	 = ["exception" => null, "id" => "id", "class" => "class"];
34
		$res1	 = "id=\"id\" class=\"class\"";
35
		$this->assertEquals($res1, StringUtility::parseArray($arg1));
36
37
		$arg2	 = ["exception" => null, "id" => "    id   ", "class" => " class "];
38
		$res2	 = "id=\"id\" class=\"class\"";
39
		$this->assertEquals($res2, StringUtility::parseArray($arg2));
40
41
		$arg3	 = ["exception" => null, "id" => "id", "class" => ["class1", "class2", "class3   class4"]];
42
		$res3	 = "id=\"id\" class=\"class1 class2 class3 class4\"";
43
		$this->assertEquals($res3, StringUtility::parseArray($arg3));
44
	}
45
46
	/**
47
	 * Tests the parseBoolean() method.
48
	 *
49
	 * @return void
50
	 */
51
	public function testParseBoolean() {
52
53
		$this->assertEquals("false", StringUtility::parseBoolean(null));
54
		$this->assertEquals("false", StringUtility::parseBoolean(false));
55
		$this->assertEquals("true", StringUtility::parseBoolean(true));
56
	}
57
58
}
59