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

DoubleUtilityTest::testParseString()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 3
eloc 15
nc 4
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 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