Passed
Push — 1 ( 67274c )
by Robbie
02:29
created

RichLinksExtensionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 28
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B testContentLinkInjections() 0 26 1
1
<?php
2
3
class RichLinksExtensionTest extends SapphireTest {
4
5
	function testContentLinkInjections() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
6
		$field = new Text();
7
8
		// External links injection.
9
		$field->setValue('<a href="http://newzealand.govt.nz">New Zealand Government</a>');
10
		$this->assertEquals(
11
			$field->RichLinks(),
12
			'<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz">New Zealand Government'
13
			.'<span class="nonvisual-indicator">(external link)</span></a>',
14
			'Injects attributes to external link without target.'
15
		);
16
17
		$field->setValue('<a href="http://newzealand.govt.nz" target="_blank">New Zealand Government</a>');
18
		$this->assertEquals(
19
			$field->RichLinks(),
20
			'<a class="external" rel="external" title="Open external link" href="http://newzealand.govt.nz" target="_blank">New Zealand Government'
21
			.'<span class="nonvisual-indicator">(external link)</span></a>',
22
			'Injects attributes to external link with target, while keeping the existing attributes.'
23
		);
24
25
		// Check the normal links are not affected.
26
		$field->setValue('<a href="[sitetree_link,id=1]">Internal</a>');
27
		$this->assertEquals(
28
			$field->RichLinks(),
29
			'<a href="[sitetree_link,id=1]">Internal</a>',
30
			'Regular link is not modified.'
31
		);
32
	}
33
}
34
35