Harjotsingh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/362264 )

Change subject: Basic Unit Tests for Quiz Extension [WIP]
......................................................................

Basic Unit Tests for Quiz Extension [WIP]

Initial test class for Quiz.class is added to check getColor method.

Bug:T159691
Change-Id: Ide874476812daaaaba70c1d2a56aa8a27dfbb99f
---
A tests/phpunit/QuizTest.php
1 file changed, 46 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quiz 
refs/changes/64/362264/1

diff --git a/tests/phpunit/QuizTest.php b/tests/phpunit/QuizTest.php
new file mode 100644
index 0000000..0970382
--- /dev/null
+++ b/tests/phpunit/QuizTest.php
@@ -0,0 +1,46 @@
+<?php
+
+class QuizTest extends MediaWikiLangTestCase {
+
+       private $quiz;
+       private $parser;
+
+        protected function setUp() {
+               parent::setUp();
+               global $wgParser, $wgOut;
+               $wgParser = $this->getParser();
+               $this->parser = &$wgParser;
+               $this->quiz = new Quiz([], $this->parser );
+       }
+
+       protected function tearDown() {
+               parent::tearDown();
+       }
+
+       private function getParser() {
+               return new StubObject(
+                       'wgParser', $GLOBALS['wgParserConf']['class'],
+                       array( $GLOBALS['wgParserConf'] )
+               );
+       }
+
+       public function provideGetColor() {
+               return [
+                       [ 'right', '#1FF72D' ],
+                       [ 'wrong', '#F74245' ],
+                       [ 'correction', '#F9F9F9' ],
+                       [ 'NA', '#2834FF' ],
+                       [ 'error', '#D700D7' ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetColor
+        * @covers Question::getColor
+        */
+       public function testGetColor( $colorId, $expected ) {
+               $color = $this->quiz->getColor( $colorId );
+               $this->assertEquals( $color, $expected );
+       }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/362264
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide874476812daaaaba70c1d2a56aa8a27dfbb99f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Harjotsingh <harjo...@ymail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to