2015-10-07 15:18:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PageImages\Tests;
|
|
|
|
|
|
|
|
use MediaWikiTestCase;
|
|
|
|
use PageImages;
|
2015-10-26 11:05:47 +00:00
|
|
|
use ParserOutput;
|
2015-10-07 15:18:54 +00:00
|
|
|
use Title;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers PageImages
|
|
|
|
*
|
|
|
|
* @group PageImages
|
|
|
|
* @group Database
|
|
|
|
*
|
2015-11-16 14:59:34 +00:00
|
|
|
* @license WTFPL 2.0
|
2015-10-07 15:18:54 +00:00
|
|
|
* @author Thiemo Mättig
|
|
|
|
*/
|
|
|
|
class PageImagesTest extends MediaWikiTestCase {
|
|
|
|
|
|
|
|
public function testPagePropertyName() {
|
|
|
|
$this->assertSame( 'page_image', PageImages::PROP_NAME );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testConstructor() {
|
|
|
|
$pageImages = new PageImages();
|
|
|
|
$this->assertInstanceOf( 'PageImages', $pageImages );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGivenNonExistingPage_getPageImageReturnsFalse() {
|
|
|
|
$title = Title::newFromText( wfRandomString() );
|
|
|
|
$title->resetArticleID( 0 );
|
|
|
|
|
|
|
|
$this->assertFalse( PageImages::getPageImage( $title ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOnLinksUpdate() {
|
2015-10-26 11:05:47 +00:00
|
|
|
$parserOutput = new ParserOutput();
|
|
|
|
$parserOutput->setExtensionData( 'pageImages', array(
|
2015-10-07 15:18:54 +00:00
|
|
|
array( 'filename' => 'A.jpg', 'fullwidth' => 100, 'fullheight' => 50 ),
|
2015-10-26 11:05:47 +00:00
|
|
|
) );
|
2015-10-07 15:18:54 +00:00
|
|
|
|
|
|
|
$linksUpdate = $this->getMockBuilder( 'LinksUpdate' )
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$linksUpdate->expects( $this->any() )
|
|
|
|
->method( 'getParserOutput' )
|
|
|
|
->will( $this->returnValue( $parserOutput ) );
|
|
|
|
|
|
|
|
$this->assertTrue( PageImages::onLinksUpdate( $linksUpdate ) );
|
2015-10-26 10:41:13 +00:00
|
|
|
$this->assertTrue( property_exists( $linksUpdate, 'mProperties' ), 'precondition' );
|
2015-10-07 15:18:54 +00:00
|
|
|
$this->assertSame( 'A.jpg', $linksUpdate->mProperties[PageImages::PROP_NAME] );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|