2015-12-23 15:08:43 +00:00
|
|
|
<?php
|
2018-08-09 09:49:10 +00:00
|
|
|
|
|
|
|
use PortableInfobox\Sanitizers\SanitizerBuilder;
|
|
|
|
|
2018-08-08 09:42:22 +00:00
|
|
|
/**
|
|
|
|
* @group PortableInfobox
|
2018-08-13 14:31:50 +00:00
|
|
|
* @covers PortableInfobox\Sanitizers\NodeSanitizer
|
2018-08-09 09:49:10 +00:00
|
|
|
* @covers PortableInfobox\Sanitizers\NodeHorizontalGroupSanitizer
|
2018-08-08 09:42:22 +00:00
|
|
|
*/
|
|
|
|
class NodeHorizontalGroupSanitizerTest extends MediaWikiTestCase {
|
2018-08-09 09:49:10 +00:00
|
|
|
/** @var PortableInfobox\Sanitizers\NodeHorizontalGroupSanitizer $sanitizer */
|
2015-12-23 15:08:43 +00:00
|
|
|
private $sanitizer;
|
|
|
|
|
|
|
|
protected function setUp() {
|
2018-08-16 09:25:53 +00:00
|
|
|
$this->sanitizer = SanitizerBuilder::createFromType( 'horizontal-group-content' );
|
2015-12-23 15:08:43 +00:00
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
2018-08-08 09:42:22 +00:00
|
|
|
protected function tearDown() {
|
|
|
|
unset( $sanitizer );
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
2015-12-23 15:08:43 +00:00
|
|
|
/**
|
|
|
|
* @param $data
|
|
|
|
* @param $expected
|
2017-03-15 18:07:51 +00:00
|
|
|
* @dataProvider sanitizeDataProvider
|
2015-12-23 15:08:43 +00:00
|
|
|
*/
|
2017-03-15 18:07:51 +00:00
|
|
|
public function testSanitize( $data, $expected ) {
|
2015-12-23 15:08:43 +00:00
|
|
|
$this->assertEquals(
|
|
|
|
$expected,
|
|
|
|
$this->sanitizer->sanitize( $data )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-03-15 18:07:51 +00:00
|
|
|
public function sanitizeDataProvider() {
|
2015-12-23 15:08:43 +00:00
|
|
|
return [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'labels' => [
|
|
|
|
0 => '<img src="money.jpg" class="test classes" width="20" />',
|
|
|
|
1 => 'Label with <a>link</a>',
|
|
|
|
2 => 'Label with <small>link</small>',
|
|
|
|
3 => 'Money <img src="money.jpg" class="test classes" width="20" />'
|
|
|
|
],
|
|
|
|
'values' => [
|
|
|
|
0 => 'Data <small>Value</small>',
|
|
|
|
1 => 'Data <a>Value</a>',
|
|
|
|
2 => '<img src="money.jpg" class="test classes" width="20" />',
|
|
|
|
3 => '$50'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'labels' => [
|
|
|
|
0 => '<img src="money.jpg" class="test classes" width="20" />',
|
|
|
|
1 => 'Label with <a>link</a>',
|
|
|
|
2 => 'Label with link',
|
|
|
|
3 => 'Money',
|
|
|
|
],
|
|
|
|
'values' => [
|
|
|
|
0 => 'Data <small>Value</small>',
|
|
|
|
1 => 'Data <a>Value</a>',
|
|
|
|
2 => '<img src="money.jpg" class="test classes" width="20" />',
|
|
|
|
3 => '$50'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|