X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FRevisionTest.php;h=39f7e5c304f2ed17478031c786aac7e6af887275;hp=80a690fbe384c7c14654cf591e50e71eda584d8f;hb=288fb8cafaa14e5bacda9316536f36fe4425b8a4;hpb=c94ffdd2f901df2b39b44b25a4985102b2e2df98 diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 80a690fbe3..39f7e5c304 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -66,11 +66,7 @@ class RevisionTest extends MediaWikiTestCase { ]; yield 'with content' => [ [ - 'content' => ContentHandler::makeContent( - 'hello world.', - Title::newFromText( 'RevisionTest_testConstructWithContent' ), - CONTENT_MODEL_JAVASCRIPT - ), + 'content' => new JavaScriptContent( 'hellow world.' ) ], ]; } @@ -85,6 +81,41 @@ class RevisionTest extends MediaWikiTestCase { $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() ); } + public function provideConstructThrowsExceptions() { + yield 'content and text_id both not empty' => [ + [ + 'content' => new WikitextContent( 'GOAT' ), + 'text_id' => 'someid', + ], + new MWException( "Text already stored in external store (id someid), " . + "can't serialize content object" ) + ]; + yield 'with bad content object (class)' => [ + [ 'content' => new stdClass() ], + new MWException( '`content` field must contain a Content object.' ) + ]; + yield 'with bad content object (string)' => [ + [ 'content' => 'ImAGoat' ], + new MWException( '`content` field must contain a Content object.' ) + ]; + yield 'bad row format' => [ + 'imastring, not a row', + new MWException( 'Revision constructor passed invalid row format.' ) + ]; + } + + /** + * @dataProvider provideConstructThrowsExceptions + */ + public function testConstructThrowsExceptions( $rowArray, Exception $expectedException ) { + $this->setExpectedException( + get_class( $expectedException ), + $expectedException->getMessage(), + $expectedException->getCode() + ); + new Revision( $rowArray ); + } + public function provideGetRevisionText() { yield 'Generic test' => [ 'This is a goat of revision text.',