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

StructuredPopupTest::testListItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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