mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-15 12:00:40 +00:00
d9df7178a0
This patch only moves existing code around, but does not change any implementation detail. I found it very suprising that all code called by this hook handler is 100% exclusive to this hook handler. There is zero interaction between this hook handlers code and all other code. Why is it in the same file then? And why is it all static? It doesn't have to be. I had to change literally nothing, except cutting and pasting, removing all "static" and replacing all "self::..." with "$this->...". That's all. Change-Id: I5ffe6fdf4e57135e6f3b32636c80f22be758607c
39 lines
1 KiB
PHP
39 lines
1 KiB
PHP
<?php
|
|
|
|
namespace PageImages\Tests\Hooks;
|
|
|
|
use PageImages\Hooks\LinksUpdateHookHandler;
|
|
use PageImages;
|
|
use ParserOutput;
|
|
use PHPUnit_Framework_TestCase;
|
|
|
|
/**
|
|
* @covers PageImages\Hooks\LinksUpdateHookHandler
|
|
*
|
|
* @group PageImages
|
|
*
|
|
* @license WTFPL 2.0
|
|
* @author Thiemo Mättig
|
|
*/
|
|
class LinksUpdateHookHandlerTest extends PHPUnit_Framework_TestCase {
|
|
|
|
public function testOnLinksUpdate() {
|
|
$parserOutput = new ParserOutput();
|
|
$parserOutput->setExtensionData( 'pageImages', array(
|
|
array( 'filename' => 'A.jpg', 'fullwidth' => 100, 'fullheight' => 50 ),
|
|
) );
|
|
|
|
$linksUpdate = $this->getMockBuilder( 'LinksUpdate' )
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$linksUpdate->expects( $this->any() )
|
|
->method( 'getParserOutput' )
|
|
->will( $this->returnValue( $parserOutput ) );
|
|
|
|
$this->assertTrue( LinksUpdateHookHandler::onLinksUpdate( $linksUpdate ) );
|
|
$this->assertTrue( property_exists( $linksUpdate, 'mProperties' ), 'precondition' );
|
|
$this->assertSame( 'A.jpg', $linksUpdate->mProperties[PageImages::PROP_NAME] );
|
|
}
|
|
|
|
}
|