mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-12-01 03:17:16 +00:00
0665baacc3
Change-Id: Idcba8dce56f7a5deea7f8dd5a126c7bdfa499064
69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace PageImages\Tests;
|
|
|
|
use IContextSource;
|
|
use MediaWikiTestCase;
|
|
use OutputPage;
|
|
use PageImages;
|
|
use SkinTemplate;
|
|
use Title;
|
|
|
|
/**
|
|
* @covers PageImages
|
|
*
|
|
* @group PageImages
|
|
* @group Database
|
|
*
|
|
* @license WTFPL
|
|
* @author Thiemo Kreuz
|
|
*/
|
|
class PageImagesTest extends MediaWikiTestCase {
|
|
|
|
public function testPagePropertyNames() {
|
|
$this->assertSame( 'page_image', PageImages::PROP_NAME );
|
|
$this->assertSame( 'page_image_free', PageImages::PROP_NAME_FREE );
|
|
}
|
|
|
|
public function testConstructor() {
|
|
$pageImages = new PageImages();
|
|
$this->assertInstanceOf( 'PageImages', $pageImages );
|
|
}
|
|
|
|
public function testGivenNonExistingPageGetPageImageReturnsFalse() {
|
|
$title = $this->newTitle();
|
|
$this->assertFalse( PageImages::getPageImage( $title ) );
|
|
}
|
|
|
|
public function testGetPropName() {
|
|
$this->assertSame( 'page_image', PageImages::getPropName( false ) );
|
|
$this->assertSame( 'page_image_free', PageImages::getPropName( true ) );
|
|
}
|
|
|
|
public function testGivenNonExistingPageOnBeforePageDisplayDoesNotAddMeta() {
|
|
$context = $this->createMock( IContextSource::class );
|
|
$context->method( 'getTitle' )
|
|
->will( $this->returnValue( $this->newTitle() ) );
|
|
|
|
$outputPage = $this->getMockBuilder( OutputPage::class )
|
|
->setMethods( [ 'addMeta' ] )
|
|
->setConstructorArgs( [ $context ] )
|
|
->getMock();
|
|
$outputPage->expects( $this->never() )
|
|
->method( 'addMeta' );
|
|
|
|
$skinTemplate = new SkinTemplate();
|
|
PageImages::onBeforePageDisplay( $outputPage, $skinTemplate );
|
|
}
|
|
|
|
/**
|
|
* @return Title
|
|
*/
|
|
private function newTitle() {
|
|
$title = Title::newFromText( 'New' );
|
|
$title->resetArticleID( 0 );
|
|
return $title;
|
|
}
|
|
|
|
}
|