XW-2415 | fix multiple warnings in tests

This commit is contained in:
Igor Rogatty 2016-12-14 15:20:10 +01:00
parent 380c2900b9
commit 7889cb59e4
4 changed files with 26 additions and 19 deletions

View file

@ -39,7 +39,12 @@ class PortableInfoboxParserTagControllerTest extends WikiaBaseTest {
protected function getXPath( $output ) {
$result = new DOMDocument();
// Surpress `Warning: DOMDocument::loadHTML(): Tag aside invalid in Entity`
// http://stackoverflow.com/questions/9149180/domdocumentloadhtml-error
libxml_use_internal_errors( true );
$result->loadHTML( $output );
libxml_use_internal_errors( false );
return new DOMXPath( $result );
}

View file

@ -22,7 +22,7 @@ class PortableInfoboxRenderServiceHelperTest extends WikiaBaseTest {
$fileHeight = isset( $input[ 'fileHeight' ] ) ? $input[ 'fileHeight' ] : null;
$fileMock = $this->getMockBuilder( 'File' )
->setConstructorArgs( [ 'TestFile' ] )
->setConstructorArgs( [ 'TestFile', false ] )
->setMethods( [ 'getWidth', 'getHeight' ] )
->getMock();
$fileMock->expects( $this->any() )

View file

@ -60,6 +60,10 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
* @return string
*/
private function normalizeHTML( $html ) {
if ( empty( $html ) ) {
return '';
}
$DOM = new DOMDocument( '1.0' );
$DOM->formatOutput = true;
$DOM->preserveWhiteSpace = false;
@ -107,7 +111,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
[
'input' => [ ],
'output' => '',
'description' => 'Empty data should yield no infobox markup'
'description' => 'Empty data should yield no infobox markup',
'mockParams' => []
],
[
'input' => [
@ -121,7 +126,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
'output' => '<aside class="portable-infobox pi-background">
<h2 class="pi-item pi-item-spacing pi-title">Test Title</h2>
</aside>',
'description' => 'Only title'
'description' => 'Only title',
'mockParams' => []
],
[
'input' => [
@ -226,7 +232,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
'output' => '<aside class="portable-infobox pi-background">
<nav class="pi-navigation pi-item-spacing pi-secondary-background pi-secondary-font">navigation value</nav>
</aside>',
'description' => 'navigation only'
'description' => 'navigation only',
'mockParams' => []
],
[
'input' => [
@ -244,7 +251,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
<div class="pi-data-value pi-font">test value</div>
</div>
</aside>',
'description' => 'Only pair'
'description' => 'Only pair',
'mockParams' => []
],
[
'input' => [
@ -330,7 +338,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
<div class="pi-data-value pi-font">test value</div>
</div>
</aside>',
'description' => 'Simple infobox with title, INVALID image and key-value pair'
'description' => 'Simple infobox with title, INVALID image and key-value pair',
'mockParams' => []
],
[
'input' => [
@ -355,7 +364,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
<div class="pi-data-value pi-font">test value</div>
</div>
</aside>',
'description' => 'Simple infobox with title, empty image and key-value pair'
'description' => 'Simple infobox with title, empty image and key-value pair',
'mockParams' => []
],
[
'input' => [
@ -407,7 +417,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
</div>
</section>
</aside>',
'description' => 'Infobox with title, group with header and two key-value pairs'
'description' => 'Infobox with title, group with header and two key-value pairs',
'mockParams' => []
],
[
'input' => [
@ -536,7 +547,8 @@ class PortableInfoboxRenderServiceTest extends WikiaBaseTest {
<p>Links</p>
</nav>
</aside>',
'description' => 'Infobox with navigation'
'description' => 'Infobox with navigation',
'mockParams' => []
],
[
'input' => [

View file

@ -171,23 +171,13 @@ class NodeImageTest extends WikiaBaseTest {
* @throws \Wikia\PortableInfobox\Parser\XmlMarkupParseErrorException
*/
public function testVideo( $markup, $params, $expected ) {
global $wgHooks;
// backup the hooks
$tmpHooks = $wgHooks[ 'PortableInfoboxNodeImage::getData' ];
$wgHooks[ 'PortableInfoboxNodeImage::getData' ] = [ ];
$fileMock = new FileMock();
$xmlObj = Wikia\PortableInfobox\Parser\XmlParser::parseXmlString( $markup );
$this->mockStaticMethod( 'WikiaFileHelper', 'getFileFromTitle', $fileMock );
$nodeImage = new Wikia\PortableInfobox\Parser\Nodes\NodeImage( $xmlObj, $params );
$this->assertEquals( $expected, $nodeImage->getData() );
// restore the hooks
$wgHooks[ 'PortableInfoboxNodeImage::getData' ] = $tmpHooks;
}
public function testVideoProvider() {