wiki.techinc.nl/tests/phpunit/unit/includes/media/TrivialMediaHandlerStateTest.php
Tim Starling f5d86ec75e Replace usage of custom File properties
Some MediaHandler subclasses were setting custom properties on the File
object in order to cache file-associated state. So:

* Add File::getHandlerState() and File::setHandlerState().
* Put them in an interface, which will be used in a subsequent commit in
  MediaHandler::getSizeAndMetadata().
* Use them in DjvuHandler.
* Provide a trivial implementation of the interface, for use in testing
  and in the subsequent commit.

Change-Id: Ic365384ff13f7898c1203da38c4405abf03d7563
2021-05-27 18:48:06 +10:00

15 lines
394 B
PHP

<?php
/**
* @covers TrivialMediaHandlerState
*/
class TrivialMediaHandlerStateTest extends MediaWikiUnitTestCase {
public function testSetHandlerState() {
$obj = new stdClass;
$state = new TrivialMediaHandlerState;
$this->assertNull( $state->getHandlerState( 'test' ) );
$state->setHandlerState( 'test', $obj );
$this->assertSame( $obj, $state->getHandlerState( 'test' ) );
}
}