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
|
|
|
|