The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
63 lines
2 KiB
PHP
63 lines
2 KiB
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
*/
|
|
|
|
class ContentHandlerSanityTest extends MediaWikiIntegrationTestCase {
|
|
|
|
public static function provideHandlers() {
|
|
$models = ContentHandler::getContentModels();
|
|
$contentHandlerFactory = MediaWikiServices::getInstance()->getContentHandlerFactory();
|
|
$handlers = [];
|
|
foreach ( $models as $model ) {
|
|
$handlers[] = [
|
|
$contentHandlerFactory->getContentHandler( $model )
|
|
];
|
|
}
|
|
|
|
return $handlers;
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideHandlers
|
|
* @param ContentHandler $handler
|
|
*/
|
|
public function testMakeEmptyContent( ContentHandler $handler ) {
|
|
$content = $handler->makeEmptyContent();
|
|
$this->assertInstanceOf( Content::class, $content );
|
|
if ( $handler instanceof TextContentHandler ) {
|
|
// TextContentHandler::getContentClass() is protected, so bypass
|
|
// that restriction
|
|
$testingWrapper = TestingAccessWrapper::newFromObject( $handler );
|
|
$this->assertInstanceOf( $testingWrapper->getContentClass(), $content );
|
|
}
|
|
|
|
$handlerClass = get_class( $handler );
|
|
$contentClass = get_class( $content );
|
|
|
|
if ( $handler->supportsDirectEditing() ) {
|
|
$this->assertTrue(
|
|
$content->isValid(),
|
|
"$handlerClass::makeEmptyContent() did not return a valid content ($contentClass::isValid())"
|
|
);
|
|
}
|
|
}
|
|
|
|
}
|