}
protected function createPage( $page, $text, $model = null ) {
- if ( is_string( $page ) ) $page = Title::newFromText( $page );
- if ( $page instanceof Title ) $page = new WikiPage( $page );
+ if ( is_string( $page ) ) {
+ if ( !preg_match( '/:/', $page ) &&
+ ( $model === null || $model === CONTENT_MODEL_WIKITEXT ) ) {
+
+ $ns = $this->getDefaultWikitextNS();
+ $page = MWNamespace::getCanonicalName( $ns ) . ':' . $page;
+ }
+
+ $page = Title::newFromText( $page );
+ }
+
+ if ( $page instanceof Title ) {
+ $page = new WikiPage( $page );
+ }
if ( $page->exists() ) {
$page->doDeleteArticle( "done" );
'missing rev_content_model in list of fields');
$this->assertTrue( in_array( 'rev_content_format', $fields ),
'missing rev_content_format in list of fields');
- } else {
- $this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
}
$userB = \User::createNew( $userB->getName() );
}
+ $ns = $this->getDefaultWikitextNS();
+
$dbw = wfGetDB( DB_MASTER );
$revisions = array();
// create revisions -----------------------------
- $page = WikiPage::factory( Title::newFromText( 'RevisionStorageTest_testUserWasLastToEdit' ) );
+ $page = WikiPage::factory( Title::newFromText(
+ 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
# zero
$revisions[0] = new Revision( array(
/**
* @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');
/**
* @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
+ }
}
}