| Conditions | 1 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | function testContentLinkInjections() { |
||
|
|
|||
| 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 | ); |
||
| 35 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.