Completed
Push — master ( 4d0076...81538e )
by Jeroen De
26s queued 11s
created

StructuredPopupTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testWithoutPropertyValues() 0 6 1
A getHtml() 0 3 1
A testTitleAndListAreSeparated() 0 6 1
A testListItems() 0 6 1
A testLinksAreAllowed() 0 6 1
A testImagesAreAllowed() 0 6 1
A testRandomTagsAreFiltered() 0 6 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\Tests\Unit\Map;
6
7
use Maps\Map\StructuredPopup;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \Maps\Map\StructuredPopup
12
 */
13
class StructuredPopupTest extends TestCase {
14
15
	public function testWithoutPropertyValues() {
16
		$this->assertSame(
17
			'<h3 style="padding-top: 0">MyTitle</h3>',
18
			$this->getHtml( 'MyTitle', [] )
19
		);
20
	}
21
22
	private function getHtml( string $titleHtml, array $propertyValues ) {
23
		return ( new StructuredPopup( $titleHtml, $propertyValues ) )->getHtml();
24
	}
25
26
	public function testTitleAndListAreSeparated() {
27
		$this->assertContains(
28
			'</h3><br><strong>',
29
			$this->getHtml( 'MyTitle', [ 'P1' => 'V1' ] )
30
		);
31
	}
32
33
	public function testListItems() {
34
		$this->assertContains(
35
			'<strong>P1</strong>: V1<br><strong>P2</strong>: V2',
36
			$this->getHtml( 'MyTitle', [ 'P1' => 'V1', 'P2' => 'V2' ] )
37
		);
38
	}
39
40
	public function testLinksAreAllowed() {
41
		$this->assertContains(
42
			'<strong><a href="#">P1</a></strong>: <a href="#">P1</a>',
43
			$this->getHtml( 'MyTitle', [ '<a href="#">P1</a>' => '<a href="#">P1</a>' ] )
44
		);
45
	}
46
47
	public function testImagesAreAllowed() {
48
		$this->assertContains(
49
			'<img src="#">',
50
			$this->getHtml( 'MyTitle', [ 'P1' => '<img src="#">' ] )
51
		);
52
	}
53
54
	public function testRandomTagsAreFiltered() {
55
		$this->assertContains(
56
			'<strong>P1</strong>: abcde',
57
			$this->getHtml( 'MyTitle', [ 'P1<script>' => '<ul><li>abc</li></ul>de' ] )
58
		);
59
	}
60
61
}
62