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

View file

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

View file

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