Merge "(bug 43964) Invalid value of "link" parameter in <gallery> no longer produces...
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionStorageTest_ContentHandlerUseDB.php
index 3dfaa8d..c372c3e 100644 (file)
@@ -43,8 +43,7 @@ class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
        /**
         * @covers Revision::selectFields
         */
-       public function testSelectFields()
-       {
+       public function testSelectFields() {
                $fields = Revision::selectFields();
 
                $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields');
@@ -59,26 +58,38 @@ class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
        /**
         * @covers Revision::getContentModel
         */
-       public function testGetContentModel()
-       {
-               $orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
-               $rev = Revision::newFromId( $orig->getId() );
-
-               //NOTE: database fields for the content_model are disabled, so the model name is not retained.
-               //      We expect to get the default here instead of what was suppleid when creating the revision.
-               $this->assertEquals( CONTENT_MODEL_WIKITEXT, $rev->getContentModel() );
+       public function testGetContentModel() {
+               try {
+                       $this->makeRevision( array( 'text' => 'hello hello.',
+                                                   'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
+
+                       $this->fail( "Creating JavaScript content on a wikitext page should fail with "
+                               . "\$wgContentHandlerUseDB disabled" );
+               } catch ( MWException $ex ) {
+                       $this->assertTrue( true ); // ok
+               }
        }
 
 
        /**
         * @covers Revision::getContentFormat
         */
-       public function testGetContentFormat()
-       {
-               $orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT, 'content_format' => 'text/javascript' ) );
-               $rev = Revision::newFromId( $orig->getId() );
-
-               $this->assertEquals( CONTENT_FORMAT_WIKITEXT, $rev->getContentFormat() );
+       public function testGetContentFormat() {
+               try {
+                       //@todo: change this to test failure on using a non-standard (but supported) format
+                       //       for a content model supported in the given location. As of 1.21, there are
+                       //       no alternative formats for any of the standard content models that could be
+                       //       used for this though.
+
+                       $this->makeRevision( array( 'text' => 'hello hello.',
+                                                   'content_model' => CONTENT_MODEL_JAVASCRIPT,
+                                                   'content_format' => 'text/javascript' ) );
+
+                       $this->fail( "Creating JavaScript content on a wikitext page should fail with "
+                               . "\$wgContentHandlerUseDB disabled" );
+               } catch ( MWException $ex ) {
+                       $this->assertTrue( true ); // ok
+               }
        }
 
 }