mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 04:22:37 +00:00
0ce0b500fe
Cover the sanitizer build step in tests too
50 lines
2.2 KiB
PHP
50 lines
2.2 KiB
PHP
<?php
|
|
|
|
class PassThroughSanitizerTest extends WikiaBaseTest {
|
|
private $sanitizer;
|
|
|
|
protected function setUp() {
|
|
$this->setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php';
|
|
|
|
$this->sanitizer = SanitizerBuilder::createFromType('invalid-type');
|
|
parent::setUp();
|
|
}
|
|
|
|
/**
|
|
* @param $data
|
|
* @param $expected
|
|
* @dataProvider testSanitizeDataProvider
|
|
*/
|
|
function testSanitize( $data, $expected ) {
|
|
$this->assertEquals(
|
|
$expected,
|
|
$this->sanitizer->sanitize( $data )
|
|
);
|
|
}
|
|
|
|
function testSanitizeDataProvider() {
|
|
return [
|
|
[
|
|
['value' => 'Test Title' ],
|
|
[ 'value' => 'Test Title' ]
|
|
],
|
|
[
|
|
['value' => ' Test Title '],
|
|
['value' => ' Test Title '],
|
|
],
|
|
[
|
|
['value' => 'Test Title <img src=\'data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D\' class=\'article-media\' data-ref=\'1\' width=\'400\' height=\'100\' /> ' ],
|
|
['value' => 'Test Title <img src=\'data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D\' class=\'article-media\' data-ref=\'1\' width=\'400\' height=\'100\' /> ' ],
|
|
],
|
|
[
|
|
['value' => 'Test Title <a href="example.com">with link</a>'],
|
|
['value' => 'Test Title <a href="example.com">with link</a>'],
|
|
],
|
|
[
|
|
['value' => 'Real world <a href="http://vignette-poz.wikia-dev.com/mediawiki116/images/b/b6/DBGT_Logo.svg/revision/latest?cb=20150601155347" class="image image-thumbnail" ><img src="http://vignette-poz.wikia-dev.com/mediawiki116/images/b/b6/DBGT_Logo.svg/revision/latest/scale-to-width-down/30?cb=20150601155347" alt="DBGT Logo" class="" data-image-key="DBGT_Logo.svg" data-image-name="DBGT Logo.svg" width="30" height="18" ></a>title example'] ,
|
|
['value' => 'Real world <a href="http://vignette-poz.wikia-dev.com/mediawiki116/images/b/b6/DBGT_Logo.svg/revision/latest?cb=20150601155347" class="image image-thumbnail" ><img src="http://vignette-poz.wikia-dev.com/mediawiki116/images/b/b6/DBGT_Logo.svg/revision/latest/scale-to-width-down/30?cb=20150601155347" alt="DBGT Logo" class="" data-image-key="DBGT_Logo.svg" data-image-name="DBGT Logo.svg" width="30" height="18" ></a>title example'] ,
|
|
],
|
|
];
|
|
}
|
|
}
|