mediawiki-extensions-PageIm.../tests/phpunit/PageImagesTest.php
Baha 382c70f981 Allow querying non-free images too
The API accepts a new query parameter `license`, whose
value can either be `free` or `any`. `free` is the default value.

When the value of `licence` is:
  * `free`, then only the best image whose copyright allows
    reusing it will be returned;
  * `any`, then the best image, regardless of its copyright
    status, will be returned.

Bug: T131105
Change-Id: I83ac5266e382d2d121aff3f7d28711787251c03b
2016-11-21 17:29:25 -05:00

42 lines
975 B
PHP

<?php
namespace PageImages\Tests;
use MediaWikiTestCase;
use PageImages;
use Title;
/**
* @covers PageImages
*
* @group PageImages
* @group Database
*
* @license WTFPL 2.0
* @author Thiemo Mättig
*/
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 testGivenNonExistingPage_getPageImageReturnsFalse() {
$title = Title::newFromText( wfRandomString() );
$title->resetArticleID( 0 );
$this->assertFalse( PageImages::getPageImage( $title ) );
}
public function testGetPropName() {
$this->assertSame( 'page_image', PageImages::getPropName( false ) );
$this->assertSame( 'page_image_free', PageImages::getPropName( true ) );
}
}