PortableInfobox/tests/sanitizers/NodeImageSanitizerTest.php

38 lines
1 KiB
PHP
Raw Normal View History

2015-12-23 14:54:03 +00:00
<?php
class NodeImageSanitizerTest extends WikiaBaseTest {
private $sanitizer;
protected function setUp() {
$this->setupFile = dirname( __FILE__ ) . '/../../PortableInfobox.setup.php';
$this->sanitizer = SanitizerBuilder::createFromType('image');
2015-12-23 14:54:03 +00:00
parent::setUp();
}
/**
* @param $data
* @param $expected
* @dataProvider testSanitizeDataProvider
*/
function testSanitize( $data, $expected ) {
$this->assertEquals(
$expected,
$this->sanitizer->sanitize( $data )
);
}
function testSanitizeDataProvider() {
return [
[
[ 'caption' => 'Test <a>Title with</a> <span><small>small</small></span> tag, span tag and <img src="sfefes"/>tag' ],
[ 'caption' => 'Test <a>Title with</a> small tag, span tag and tag' ]
],
[
[ 'caption' => '<a href="http://vignette-poz.wikia-dev.com//images/9/95/All_Stats_%2B2.png/revision/latest?cb=20151222111955" class="image image-thumbnail"><img src="abc" alt="All Stats +2" class="thumbimage" /></a>' ],
2015-12-28 09:16:33 +00:00
[ 'caption' => '' ],
2015-12-23 14:54:03 +00:00
]
];
}
}