Passed
Push — GlobeCoordinateParser ( 7d8c3a )
by Jeroen De
02:26
created

testToFloatReturnsConstructorValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Tests\DataValues\Geo\Values;
6
7
use DataValues\Geo\Values\Precision;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \DataValues\Geo\Values\Precision
12
 *
13
 * @license GPL-2.0-or-later
14
 * @author Jeroen De Dauw < [email protected] >
15
 */
16
class PrecisionTest extends TestCase {
17
18
	public function testConstructorThrowsExceptionForTooHighValues() {
19
		$this->expectException( \InvalidArgumentException::class );
20
		new Precision( 360.1 );
21
	}
22
23
	public function testConstructorThrowsExceptionForTooLowValues() {
24
		$this->expectException( \InvalidArgumentException::class );
25
		new Precision( -360.1 );
26
	}
27
28
	/**
29
	 * @dataProvider validDegreeProvider
30
	 */
31
	public function testToFloatReturnsConstructorValue( float $validDegree ) {
32
		$this->assertSame(
33
			$validDegree,
34
			( new Precision( $validDegree ) )->toFloat()
35
		);
36
	}
37
38
	public function validDegreeProvider() {
39
		yield [ 360 ];
40
		yield [ -360 ];
41
		yield [ 0 ];
42
		yield [ 1 ];
43
		yield [ -1 ];
44
		yield [ 0.1 ];
45
		yield [ 0.000001 ];
46
		yield [ 0.123456 ];
47
	}
48
49
}
50