mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-12-04 20:59:45 +00:00
d81dfe6e9e
Bug: T170583 Change-Id: I76ed85cf960269c5692e9ec8c92877bcb13e4100
65 lines
1.5 KiB
PHP
65 lines
1.5 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 2.0
|
|
* @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->getMock( IContextSource::class );
|
|
$context->method( 'getTitle' )
|
|
->will( $this->returnValue( $this->newTitle() ) );
|
|
|
|
$outputPage = $this->getMock( OutputPage::class, null, [ $context ] );
|
|
$outputPage->expects( $this->never() )
|
|
->method( 'addMeta' );
|
|
|
|
PageImages::onBeforePageDisplay( $outputPage, new SkinTemplate() );
|
|
}
|
|
|
|
/**
|
|
* @return Title
|
|
*/
|
|
private function newTitle() {
|
|
$title = Title::newFromText( 'New' );
|
|
$title->resetArticleID( 0 );
|
|
return $title;
|
|
}
|
|
|
|
}
|