MediaWiki  1.34.0
PageImagesTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace PageImages\Tests;
4 
6 use MediaWikiTestCase;
7 use OutputPage;
8 use PageImages;
9 use SkinTemplate;
10 use Title;
11 
21 class PageImagesTest extends MediaWikiTestCase {
22 
23  public function testPagePropertyNames() {
24  $this->assertSame( 'page_image', PageImages::PROP_NAME );
25  $this->assertSame( 'page_image_free', PageImages::PROP_NAME_FREE );
26  }
27 
28  public function testConstructor() {
29  $pageImages = new PageImages();
30  $this->assertInstanceOf( 'PageImages', $pageImages );
31  }
32 
34  $title = $this->newTitle();
35  $this->assertFalse( PageImages::getPageImage( $title ) );
36  }
37 
38  public function testGetPropName() {
39  $this->assertSame( 'page_image', PageImages::getPropName( false ) );
40  $this->assertSame( 'page_image_free', PageImages::getPropName( true ) );
41  }
42 
44  $context = $this->getMock( IContextSource::class );
45  $context->method( 'getTitle' )
46  ->will( $this->returnValue( $this->newTitle() ) );
47 
48  $outputPage = $this->getMock(
49  OutputPage::class, [ 'addMeta' ], [ $context ] );
50  $outputPage->expects( $this->never() )
51  ->method( 'addMeta' );
52 
53  $skinTemplate = new SkinTemplate();
54  PageImages::onBeforePageDisplay( $outputPage, $skinTemplate );
55  }
56 
60  private function newTitle() {
61  $title = Title::newFromText( 'New' );
62  $title->resetArticleID( 0 );
63  return $title;
64  }
65 
66 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:316
PageImages\PROP_NAME_FREE
const PROP_NAME_FREE
Page property used to store the best free page image information Note changing this value is not advi...
Definition: PageImages.php:28
PageImages\Tests\PageImagesTest\testGivenNonExistingPageGetPageImageReturnsFalse
testGivenNonExistingPageGetPageImageReturnsFalse()
Definition: PageImagesTest.php:33
PageImages\getPageImage
static getPageImage(Title $title)
Returns page image for a given title.
Definition: PageImages.php:49
PageImages
PageImages\onBeforePageDisplay
static onBeforePageDisplay(OutputPage &$out, Skin &$skin)
Definition: PageImages.php:202
PageImages\Tests\PageImagesTest\testGivenNonExistingPageOnBeforePageDisplayDoesNotAddMeta
testGivenNonExistingPageOnBeforePageDisplayDoesNotAddMeta()
Definition: PageImagesTest.php:43
PageImages\Tests\PageImagesTest\newTitle
newTitle()
Definition: PageImagesTest.php:60
PageImages\Tests\PageImagesTest\testPagePropertyNames
testPagePropertyNames()
Definition: PageImagesTest.php:23
$title
$title
Definition: testCompression.php:34
PageImages\Tests
Definition: ApiQueryPageImagesProxyMock.php:3
PageImages\PROP_NAME
const PROP_NAME
Page property used to store the best page image information.
Definition: PageImages.php:20
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
$context
$context
Definition: load.php:45
Title
Represents a title within MediaWiki.
Definition: Title.php:42
PageImages\getPropName
static getPropName( $isFree)
Get property name used in page_props table.
Definition: PageImages.php:38
PageImages\Tests\PageImagesTest\testGetPropName
testGetPropName()
Definition: PageImagesTest.php:38
SkinTemplate
Base class for template-based skins.
Definition: SkinTemplate.php:38
PageImages\Tests\PageImagesTest
@covers PageImages
Definition: PageImagesTest.php:21
PageImages\Tests\PageImagesTest\testConstructor
testConstructor()
Definition: PageImagesTest.php:28