jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/366280 )
Change subject: Add tests for shuffle control tags {X}, {!X} and {/X}
......................................................................
Add tests for shuffle control tags {X}, {!X} and {/X}
This change adds tests for shuffle control.The testParseQuestion function
requires $input array for ParseQuestion, $expected value to assertEquals,
injected value for mShuffleDiv and expected value for mShuffleDiv after
output is returned from ParseQuesiton.Two assertions are made for each
test case.
Bug: T167635
Change-Id: Ie2b66d949aacd3830e669c6b2d5ec4b0cee8fbcd
---
M tests/phpunit/QuizTest.php
1 file changed, 44 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Mvolz: Looks good to me, approved
diff --git a/tests/phpunit/QuizTest.php b/tests/phpunit/QuizTest.php
index 1615378..a012526 100644
--- a/tests/phpunit/QuizTest.php
+++ b/tests/phpunit/QuizTest.php
@@ -9,7 +9,10 @@
parent::setUp();
global $wgParser;
$wgParser = $this->getParser();
+ $options = new ParserOptions();
+ $title = $wgParser->getTitle();
$this->parser = &$wgParser;
+ $this->parser->startExternalParse( $title, $options, 'text',
true );
$this->quiz = new Quiz( [], $this->parser );
}
@@ -53,4 +56,45 @@
$this->assertEquals( 0, $this->quiz->getQuizId() );
}
+ public function provideParseQuestion() {
+ return [
+ // Test for {X} tag
+ [
+ [ [ 'X}', 'X', '' ], '1' ],
+ '<div class="shuffle">' . "\n", '0', '1'
+ ],
+ // Test for {!X} tag
+ [
+ [ [ '!X}', '!X', '' ], '1' ],
+ '<div class="noshuffle">' . "\n", '0', '1'
+ ],
+ // Test for {/X} tag when {X} or {!X} has been used
previously
+ [
+ [ [ '/X}', '/X', '' ], '1' ],
+ '', '0', '0'
+ ],
+ // Test for {/X} tag when {X} or {!X} has not been used
previously
+ [
+ [ [ '/X}', '/X', '' ], '1' ],
+ '</div>' . "\n", '1', '0'
+ ],
+ // Test when random value is passed inside {} tag
+ [
+ [ [ 'abc}', 'abc', '' ], '1' ],
+ '<div class="quizText">abc<br /></div>' . "\n", '0',
'0'
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider provideParseQuestion
+ * @covers Question::parseQuestion
+ */
+ public function testParseQuestion( $input, $expected, $injectedValue,
$expectedValue ) {
+ $this->quiz->mShuffleDiv = $injectedValue;
+ $output = $this->quiz->parseQuestion( $input[0], $input[1] );
+ $this->assertEquals( $this->quiz->mShuffleDiv, $expectedValue );
+ $this->assertEquals( $output, $expected );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/366280
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie2b66d949aacd3830e669c6b2d5ec4b0cee8fbcd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Harjotsingh <[email protected]>
Gerrit-Reviewer: Mvolz <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits