PolygonTest::assertHasJsonKeyWithValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Tests\Unit\LegacyModel;
6
7
use Maps\LegacyModel\Polygon;
8
9
/**
10
 * @covers \Maps\LegacyModel\Polygon
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class PolygonTest extends LineTest {
16
17
	/**
18
	 * @see BaseElementTest::getClass
19
	 *
20
	 * @since 3.0
21
	 *
22
	 * @return string
23
	 */
24
	public function getClass() {
25
		return Polygon::class;
26
	}
27
28
	/**
29
	 * @dataProvider instanceProvider
30
	 */
31
	public function testSetOnlyVisibleOnHover( Polygon $polygon ) {
32
		$this->assertFalse( $polygon->isOnlyVisibleOnHover() );
33
34
		$polygon->setOnlyVisibleOnHover( true );
35
		$this->assertTrue( $polygon->isOnlyVisibleOnHover() );
36
37
		$polygon->setOnlyVisibleOnHover( false );
38
		$this->assertFalse( $polygon->isOnlyVisibleOnHover() );
39
	}
40
41
	/**
42
	 * @dataProvider instanceProvider
43
	 */
44
	public function testSetFillOpacity( Polygon $polygon ) {
45
		$polygon->setFillOpacity( '0.42' );
46
		$this->assertHasJsonKeyWithValue( $polygon, 'fillOpacity', '0.42' );
47
	}
48
49
	protected function assertHasJsonKeyWithValue( Polygon $polygon, $key, $value ) {
50
		$json = $polygon->getJSONObject();
51
52
		$this->assertArrayHasKey( $key, $json );
53
		$this->assertEquals(
54
			$value,
55
			$json[$key]
56
		);
57
	}
58
59
	/**
60
	 * @dataProvider instanceProvider
61
	 */
62
	public function testSetFillColor( Polygon $polygon ) {
63
		$polygon->setFillColor( '#FFCCCC' );
64
		$this->assertHasJsonKeyWithValue( $polygon, 'fillColor', '#FFCCCC' );
65
	}
66
67
}
68
69
70
71