PortableInfobox/tests/phpunit/sanitizers/NodeHorizontalGroupSanitizerTest.php

67 lines
1.5 KiB
PHP
Raw Normal View History

2015-12-23 15:08:43 +00:00
<?php
2018-08-08 09:42:22 +00:00
/**
* @group PortableInfobox
* @covers NodeDataSanitizer
*/
class NodeHorizontalGroupSanitizerTest extends MediaWikiTestCase {
2017-03-15 18:07:51 +00:00
/** @var NodeHorizontalGroupSanitizer $sanitizer */
2015-12-23 15:08:43 +00:00
private $sanitizer;
protected function setUp() {
$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'
]
]
]
];
}
}