Completed
Push — MediaWikiFileUrlFinderTest ( d58bee )
by Jeroen De
03:36
created

PolygonTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 53
rs 10
c 0
b 0
f 0

5 Methods

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