r23605 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23604‎ | r23605 | r23606 >
Date:14:34, 1 July 2007
Author:kim
Status:old
Tags:
Comment:
Work on unit tests
Test.skeleton.php can be used to write future PHPUnit test cases.

RecordHelperTest.php is a (still skeletal) PHPUnit test case for RecordHelper.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/GetDM.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordHelper.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/RecordHelperTest.php (added) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Test.skeleton.php (added) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/GetDM.php
@@ -2,7 +2,7 @@
33
44 define('MEDIAWIKI', true );
55
6 -# do we seriously need ALL of thesE?
 6+# do we seriously need ALL of these?
77 require_once("../../../StartProfiler.php");
88 require_once("../../../LocalSettings.php");
99 require_once("../php-tools/ProgressBar.php");
@@ -13,20 +13,21 @@
1414
1515
1616 global
17 -$beginTime, $wgCommandLineMode;
 17+$beginTime, $wgCommandLineMode, $dc;
1818
1919 $beginTime = time();
2020 $wgCommandLineMode = true;
21 -$dc = "uw";
 21+# $dc = "uw"; < can't modify from here
2222
2323 /* insert code here */
24 -$definedMeaningId=1087; # education
 24+$definedMeaningId=663665; # UnitTest
2525 $filterLanguageId=0; # ??? What does this do ???
2626 $possiblySynonymousRelationTypeId=0; # ??? What does this do ???
2727 $queryTransactionInformation= new QueryLatestTransactionInformation();
2828
2929 $model=new DefinedMeaningModel($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation);
3030 $record=$model->getRecord();
 31+$record->finish("DefinedMeaning");
3132 echo $record;
3233
3334
Index: trunk/extensions/Wikidata/OmegaWiki/Test.skeleton.php
@@ -0,0 +1,64 @@
 2+<?php
 3+
 4+# Empty skeleton for omegawiki test cases.
 5+# Replace occurences of RecordHelperTest with the name of your own test case.
 6+
 7+
 8+define('MEDIAWIKI', true );
 9+
 10+if (!defined("PHPUnit_MAIN_METHOD")) {
 11+ define("PHPUnit_MAIN_METHOD", "RecordHelperTest::main");
 12+}
 13+
 14+
 15+# do we seriously need ALL of these?
 16+require_once("../../../StartProfiler.php");
 17+require_once("../../../LocalSettings.php");
 18+require_once("../php-tools/ProgressBar.php");
 19+require_once("Setup.php");
 20+require_once("DefinedMeaningModel.php");
 21+require_once("Transaction.php");
 22+
 23+require_once "PHPUnit/Framework/TestCase.php";
 24+require_once "PHPUnit/Framework/TestSuite.php";
 25+require_once("RecordHelper.php");
 26+
 27+
 28+
 29+class RecordHelperTest extends PHPUnit_Framework_TestCase {
 30+
 31+ var $testRecord;
 32+
 33+ public static function main() {
 34+ require_once "PHPUnit/TextUI/TestRunner.php";
 35+
 36+ $suite = new PHPUnit_Framework_TestSuite("somethingTest");
 37+ $result = PHPUnit_TextUI_TestRunner::run($suite);
 38+ }
 39+
 40+
 41+ function setUp() {
 42+
 43+ global $wgCommandLineMode;
 44+ $wgCommandLineMode = true;
 45+ $dc = "uw";
 46+ $definedMeaningId=663665; # education
 47+ $filterLanguageId=0; # ??? What does this do ???
 48+ $possiblySynonymousRelationTypeId=0; # ??? What does this do ???
 49+ $queryTransactionInformation= new QueryLatestTransactionInformation();
 50+
 51+ $model=new DefinedMeaningModel($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation);
 52+ $testRecord=$model->getRecord();
 53+ }
 54+
 55+ function tearDown() {
 56+ $testRecord=NULL;
 57+ }
 58+
 59+}
 60+
 61+if (PHPUnit_MAIN_METHOD == "RecordHelperTest::main") {
 62+ RecordHelperTest::main();
 63+}
 64+
 65+?>
Index: trunk/extensions/Wikidata/OmegaWiki/RecordHelperTest.php
@@ -0,0 +1,62 @@
 2+<?php
 3+
 4+define('MEDIAWIKI', true );
 5+
 6+if (!defined("PHPUnit_MAIN_METHOD")) {
 7+ define("PHPUnit_MAIN_METHOD", "RecordHelperTest::main");
 8+}
 9+
 10+
 11+# do we seriously need ALL of these?
 12+require_once("../../../StartProfiler.php");
 13+require_once("../../../LocalSettings.php");
 14+global $kimwgBLA, $IP;
 15+echo "SHOULD GET\n";
 16+echo $kimwgBLA." ".$IP;
 17+echo "\n";
 18+require_once("../php-tools/ProgressBar.php");
 19+require_once("Setup.php");
 20+require_once("DefinedMeaningModel.php");
 21+require_once("Transaction.php");
 22+
 23+require_once "PHPUnit/Framework/TestCase.php";
 24+require_once "PHPUnit/Framework/TestSuite.php";
 25+require_once("RecordHelper.php");
 26+
 27+class RecordHelperTest extends PHPUnit_Framework_TestCase {
 28+
 29+ var $testRecord;
 30+
 31+ public static function main() {
 32+ require_once "PHPUnit/TextUI/TestRunner.php";
 33+
 34+ $suite = new PHPUnit_Framework_TestSuite("somethingTest");
 35+ $result = PHPUnit_TextUI_TestRunner::run($suite);
 36+ }
 37+
 38+
 39+ function setUp() {
 40+
 41+ global $wgCommandLineMode;
 42+ $wgCommandLineMode = true;
 43+ $dc = "uw";
 44+ $definedMeaningId=663665; # education
 45+ $filterLanguageId=0; # ??? What does this do ???
 46+ $possiblySynonymousRelationTypeId=0; # ??? What does this do ???
 47+ $queryTransactionInformation= new QueryLatestTransactionInformation();
 48+
 49+ $model=new DefinedMeaningModel($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation);
 50+ $testRecord=$model->getRecord();
 51+ }
 52+
 53+ function tearDown() {
 54+ $testRecord=NULL;
 55+ }
 56+
 57+}
 58+
 59+if (PHPUnit_MAIN_METHOD == "RecordHelperTest::main") {
 60+ RecordHelperTest::main();
 61+}
 62+
 63+?>
Index: trunk/extensions/Wikidata/OmegaWiki/RecordHelper.php
@@ -37,10 +37,13 @@
3838 break;
3939 case "collection-meaning":
4040 return new CollectionMeaningHelper($record);
 41+ break;
4142 case "goto-source":
4243 return new GotoSourceHelper($record);
 44+ break;
4345 case "defined-meaning-attributes":
4446 return new DefinedMeaningAttributesHelper($record);
 47+ break;
4548 default :
4649 echo "IGIVEUP ($type) I Give Up! \n";
4750 break;
@@ -51,10 +54,19 @@
5255
5356 abstract class Helper {
5457 protected $record;
 58+ protected $saved;
5559 public function __construct($record) {
5660 $this->record=$record;
5761 }
5862
 63+ public function isSaved() {
 64+ return $this->saved;
 65+ }
 66+
 67+ public function setSaved($saved) {
 68+ $this->saved=$saved;
 69+ }
 70+
5971 //public abstract function getSQL();
6072 //public abstract function save();
6173

Status & tagging log