change variable names and add missing PHPdocs

This commit is contained in:
dianafa 2015-11-03 17:19:29 +01:00
parent 2214b5c81f
commit 649895d4cf
3 changed files with 12 additions and 9 deletions

View file

@ -69,20 +69,20 @@ class PortableInfoboxRenderServiceHelper {
/**
* process single title or label
*
* @param $elementData
* @param $elementText
* @param string $allowedTags
* @return string
*/
private function sanitizeElementData( $elementData, $allowedTags = '' ) {
if ( !empty( $elementData ) ) {
$strippedElementData = trim( strip_tags( $elementData, $allowedTags ) );
private function sanitizeElementData( $elementText, $allowedTags = null ) {
if ( !empty( $elementText ) ) {
$elementTextAfterTrim = trim( strip_tags( $elementText, $allowedTags ) );
if ( $strippedElementData !== $elementData ) {
\Wikia\Logger\WikiaLogger::instance()->info( 'Striping HTML tags from infobox element' );
$elementData = $strippedElementData;
if ( $elementTextAfterTrim !== $elementText ) {
WikiaLogger::instance()->info( 'Striping HTML tags from infobox element' );
$elementText = $elementTextAfterTrim;
}
}
return $elementData;
return $elementText;
}
/**

View file

@ -41,6 +41,8 @@ class PortableInfoboxRenderService extends WikiaService {
*
* @param array $infoboxdata
*
* @param $theme
* @param $layout
* @return string - infobox HTML
*/
public function renderInfobox( array $infoboxdata, $theme, $layout ) {

View file

@ -65,13 +65,14 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
* @param $input
* @param $expectedOutput
* @param $description
* @param $mockParams
* @dataProvider testRenderInfoboxDataProvider
*/
public function testRenderInfobox( $input, $expectedOutput, $description, $mockParams ) {
$this->mockInfoboxRenderServiceHelper( $mockParams );
$infoboxRenderService = new PortableInfoboxRenderService();
$actualOutput = $infoboxRenderService->renderInfobox( $input );
$actualOutput = $infoboxRenderService->renderInfobox( $input, null, null );
$expectedHtml = $this->normalizeHTML( $expectedOutput) ;
$actualHtml = $this->normalizeHTML( $actualOutput );