parent::tearDown();
}
- function testGetRevisionText() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionText() {
$row = new stdClass;
$row->old_flags = '';
$row->old_text = 'This is a bunch of revision text.';
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextGzip() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextGzip() {
$this->checkPHPExtension( 'zlib' );
$row = new stdClass;
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8Native() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8Native() {
$row = new stdClass;
$row->old_flags = 'utf-8';
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8Legacy() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8Legacy() {
$row = new stdClass;
$row->old_flags = '';
$row->old_text = "Wiki est l'\xe9cole superieur !";
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8NativeGzip() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8NativeGzip() {
$this->checkPHPExtension( 'zlib' );
$row = new stdClass;
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8LegacyGzip() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8LegacyGzip() {
$this->checkPHPExtension( 'zlib' );
$row = new stdClass;
Revision::getRevisionText( $row ) );
}
- function testCompressRevisionTextUtf8() {
+ /**
+ * @covers Revision::compressRevisionText
+ */
+ public function testCompressRevisionTextUtf8() {
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = Revision::compressRevisionText( $row->old_text );
Revision::getRevisionText( $row ), "getRevisionText" );
}
- function testCompressRevisionTextUtf8Gzip() {
+ /**
+ * @covers Revision::compressRevisionText
+ */
+ public function testCompressRevisionTextUtf8Gzip() {
$this->checkPHPExtension( 'zlib' );
-
- global $wgCompressRevisions;
- $wgCompressRevisions = true;
+ $this->setMwGlobals( 'wgCompressRevisions', true );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
* @param string $text
* @param string $title
* @param string $model
+ * @param null $format
+ *
* @return Revision
*/
function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
$rev = new Revision(
array(
- 'id' => 42,
- 'page' => 23,
- 'title' => $title,
+ 'id' => 42,
+ 'page' => 23,
+ 'title' => $title,
- 'content' => $content,
- 'length' => $content->getSize(),
- 'comment' => "testing",
+ 'content' => $content,
+ 'length' => $content->getSize(),
+ 'comment' => "testing",
'minor_edit' => false,
'content_format' => $format,
return array(
array( 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ),
array( 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ),
- array( serialize('hello world'), 'Dummy:Hello', null, null, "testing" ),
+ array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ),
);
}
/**
* @group Database
* @dataProvider dataGetContentModel
+ * @covers Revision::getContentModel
*/
- function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
+ public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedModel, $rev->getContentModel() );
array( 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ),
array( 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ),
array( 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ),
- array( serialize('hello world'), 'Dummy:Hello', null, null, "testing" ),
+ array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ),
);
}
/**
* @group Database
* @dataProvider dataGetContentFormat
+ * @covers Revision::getContentFormat
*/
- function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
+ public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedFormat, $rev->getContentFormat() );
return array(
array( 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ),
array( 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ),
- array( serialize('hello world'), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ),
+ array( serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ),
);
}
/**
* @group Database
* @dataProvider dataGetContentHandler
+ * @covers Revision::getContentHandler
*/
- function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
+ public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
//NOTE: we expect the help namespace to always contain wikitext
return array(
array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
- array( serialize('hello world'), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize('hello world') ),
- array( serialize('hello world'), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize('hello world') ),
+ array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
+ array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
);
}
/**
* @group Database
* @dataProvider dataGetContent
+ * @covers Revision::getContent
*/
- function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+ public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$content = $rev->getContent( $audience );
//NOTE: we expect the help namespace to always contain wikitext
return array(
array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
- array( serialize('hello world'), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ),
- array( serialize('hello world'), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ),
+ array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ),
+ array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ),
);
}
/**
* @group Database
* @dataProvider dataGetText
+ * @covers Revision::getText
*/
- function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
+ public function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
$this->hideDeprecated( 'Revision::getText' );
$rev = $this->newTestRevision( $text, $title, $model, $format );
/**
* @group Database
* @dataProvider dataGetText
+ * @covers Revision::getRawText
*/
- function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
+ public function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
$this->hideDeprecated( 'Revision::getRawText' );
$rev = $this->newTestRevision( $text, $title, $model, $format );
}
- public function dataGetSize( ) {
+ public function dataGetSize() {
return array(
array( "hello world.", CONTENT_MODEL_WIKITEXT, 12 ),
array( serialize( "hello world." ), "testing", 12 ),
$this->assertEquals( $expected_size, $rev->getSize() );
}
- public function dataGetSha1( ) {
+ public function dataGetSha1() {
return array(
array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
$this->assertEquals( $expected_hash, $rev->getSha1() );
}
+ /**
+ * @covers Revision::__construct
+ */
public function testConstructWithText() {
$this->hideDeprecated( "Revision::getText" );
$rev = new Revision( array(
- 'text' => 'hello world.',
- 'content_model' => CONTENT_MODEL_JAVASCRIPT
- ));
+ 'text' => 'hello world.',
+ 'content_model' => CONTENT_MODEL_JAVASCRIPT
+ ) );
$this->assertNotNull( $rev->getText(), 'no content text' );
$this->assertNotNull( $rev->getContent(), 'no content object available' );
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
}
+ /**
+ * @covers Revision::__construct
+ */
public function testConstructWithContent() {
$this->hideDeprecated( "Revision::getText" );
$title = Title::newFromText( 'RevisionTest_testConstructWithContent' );
$rev = new Revision( array(
- 'content' => ContentHandler::makeContent( 'hello world.', $title, CONTENT_MODEL_JAVASCRIPT ),
- ));
+ 'content' => ContentHandler::makeContent( 'hello world.', $title, CONTENT_MODEL_JAVASCRIPT ),
+ ) );
$this->assertNotNull( $rev->getText(), 'no content text' );
$this->assertNotNull( $rev->getContent(), 'no content object available' );
* Tests whether $rev->getContent() returns a clone when needed.
*
* @group Database
+ * @covers Revision::getContent
*/
- function testGetContentClone( ) {
+ public function testGetContentClone() {
$content = new RevisionTestModifyableContent( "foo" );
$rev = new Revision(
array(
- 'id' => 42,
- 'page' => 23,
- 'title' => Title::newFromText( "testGetContentClone_dummy" ),
+ 'id' => 42,
+ 'page' => 23,
+ 'title' => Title::newFromText( "testGetContentClone_dummy" ),
- 'content' => $content,
- 'length' => $content->getSize(),
- 'comment' => "testing",
+ 'content' => $content,
+ 'length' => $content->getSize(),
+ 'comment' => "testing",
'minor_edit' => false,
)
);
* Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
*
* @group Database
+ * @covers Revision::getContent
*/
- function testGetContentUncloned() {
+ public function testGetContentUncloned() {
$rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT );
$content = $rev->getContent( Revision::RAW );
$content2 = $rev->getContent( Revision::RAW );
// for immutable content like wikitext, this should be the same object
$this->assertSame( $content, $content2 );
}
-
}
class RevisionTestModifyableContent extends TextContent {
parent::__construct( $text, "RevisionTestModifyableContent" );
}
- public function copy( ) {
+ public function copy() {
return new RevisionTestModifyableContent( $this->mText );
}
public function setText( $text ) {
$this->mText = $text;
}
-
}
class RevisionTestModifyableContentHandler extends TextContentHandler {
- public function __construct( ) {
+ public function __construct() {
parent::__construct( "RevisionTestModifyableContent", array( CONTENT_FORMAT_TEXT ) );
}