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

DoubleUtilityTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testParseString() 0 21 3
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 Exception;
15
use PHPUnit_Framework_TestCase;
16
use WBW\Library\Core\Exception\Argument\DoubleArgumentException;
17
use WBW\Library\Core\Utility\DoubleUtility;
18
19
/**
20
 * Double utility test.
21
 *
22
 * @author NdC/WBW <https://github.com/webeweb/>
23
 * @package WBW\Library\Core\Tests\Utility
24
 * @final
25
 */
26
final class DoubleUtilityTest extends PHPUnit_Framework_TestCase {
27
28
	/**
29
	 * Tests the parseString() method.
30
	 *
31
	 * @return void
32
	 */
33
	public function testParseString() {
34
35
		try {
36
			DoubleUtility::parseString("exception");
37
		} catch (Exception $ex) {
38
			$this->assertInstanceOf(DoubleArgumentException::class, $ex);
39
			$this->assertEquals("The argument \"exception\" is not a double", $ex->getMessage());
40
		}
41
42
		try {
43
			DoubleUtility::parseString("1A");
44
		} catch (Exception $ex) {
45
			$this->assertInstanceOf(DoubleArgumentException::class, $ex);
46
			$this->assertEquals("The argument \"1A\" is not a double", $ex->getMessage());
47
		}
48
49
		$this->assertEquals(null, DoubleUtility::parseString(null));
50
		$this->assertEquals(1.0, DoubleUtility::parseString("1"));
51
		$this->assertEquals(1.0, DoubleUtility::parseString("1."));
52
		$this->assertEquals(1.0, DoubleUtility::parseString("1.0"));
53
	}
54
55
}
56