Add 3D filetype for STL files
[lhc/web/wiklou.git] / tests / phpunit / structure / ContentHandlerSanityTest.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 */
18
19 class ContentHandlerSanityTest extends MediaWikiTestCase {
20
21 public static function provideHandlers() {
22 $models = ContentHandler::getContentModels();
23 $handlers = [];
24 foreach ( $models as $model ) {
25 $handlers[] = [ ContentHandler::getForModelID( $model ) ];
26 }
27
28 return $handlers;
29 }
30
31 /**
32 * @dataProvider provideHandlers
33 * @param ContentHandler $handler
34 */
35 public function testMakeEmptyContent( ContentHandler $handler ) {
36 $content = $handler->makeEmptyContent();
37 $this->assertInstanceOf( Content::class, $content );
38 if ( $handler instanceof TextContentHandler ) {
39 // TextContentHandler::getContentClass() is protected, so bypass
40 // that restriction
41 $testingWrapper = TestingAccessWrapper::newFromObject( $handler );
42 $this->assertInstanceOf( $testingWrapper->getContentClass(), $content );
43 }
44
45 $handlerClass = get_class( $handler );
46 $contentClass = get_class( $content );
47
48 if ( $handler->supportsDirectEditing() ) {
49 $this->assertTrue(
50 $content->isValid(),
51 "$handlerClass::makeEmptyContent() did not return a valid content ($contentClass::isValid())"
52 );
53 }
54 }
55
56 }