diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2012-11-07 20:39:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2012-11-07 20:39:09 +0000 |
commit | a8644b99bba376b80cd6d9e064c21b91de7351e4 (patch) | |
tree | 59768e7d1fd40ea6b1e5bdc5b30bf531fedd032d /tests/phpunit/includes/content/TextContentTest.php | |
parent | f77259e9aa576642fd892db0230c138b6e27a6ae (diff) | |
parent | ea4473037d0cad16286b80bb6c5bafe06c4dafd8 (diff) | |
download | mediawikicore-a8644b99bba376b80cd6d9e064c21b91de7351e4.tar.gz mediawikicore-a8644b99bba376b80cd6d9e064c21b91de7351e4.zip |
Merge "Content::convert() for conv. betw. content models."
Diffstat (limited to 'tests/phpunit/includes/content/TextContentTest.php')
-rw-r--r-- | tests/phpunit/includes/content/TextContentTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index c867a83e2e41..337945db530a 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -378,4 +378,49 @@ class TextContentTest extends MediaWikiTestCase { } } + public static function provideConvert() { + return array( + array( // #0 + 'Hallo Welt', + CONTENT_MODEL_WIKITEXT, + 'lossless', + 'Hallo Welt' + ), + array( // #1 + 'Hallo Welt', + CONTENT_MODEL_WIKITEXT, + 'lossless', + 'Hallo Welt' + ), + array( // #1 + 'Hallo Welt', + CONTENT_MODEL_CSS, + 'lossless', + 'Hallo Welt' + ), + array( // #1 + 'Hallo Welt', + CONTENT_MODEL_JAVASCRIPT, + 'lossless', + 'Hallo Welt' + ), + ); + } + + /** + * @dataProvider provideConvert + */ + public function testConvert( $text, $model, $lossy, $expectedNative ) { + $content = $this->newContent( $text ); + + $converted = $content->convert( $model, $lossy ); + + if ( $expectedNative === false ) { + $this->assertFalse( $converted, "conversion to $model was expected to fail!" ); + } else { + $this->assertInstanceOf( 'Content', $converted ); + $this->assertEquals( $expectedNative, $converted->getNativeData() ); + } + } + } |