Index: trunk/extensions/Wikidata/OmegaWiki/GetDM.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | define('MEDIAWIKI', true ); |
5 | 5 | |
6 | | -# do we seriously need ALL of thesE? |
| 6 | +# do we seriously need ALL of these? |
7 | 7 | require_once("../../../StartProfiler.php"); |
8 | 8 | require_once("../../../LocalSettings.php"); |
9 | 9 | require_once("../php-tools/ProgressBar.php"); |
— | — | @@ -13,20 +13,21 @@ |
14 | 14 | |
15 | 15 | |
16 | 16 | global |
17 | | -$beginTime, $wgCommandLineMode; |
| 17 | +$beginTime, $wgCommandLineMode, $dc; |
18 | 18 | |
19 | 19 | $beginTime = time(); |
20 | 20 | $wgCommandLineMode = true; |
21 | | -$dc = "uw"; |
| 21 | +# $dc = "uw"; < can't modify from here |
22 | 22 | |
23 | 23 | /* insert code here */ |
24 | | -$definedMeaningId=1087; # education |
| 24 | +$definedMeaningId=663665; # UnitTest |
25 | 25 | $filterLanguageId=0; # ??? What does this do ??? |
26 | 26 | $possiblySynonymousRelationTypeId=0; # ??? What does this do ??? |
27 | 27 | $queryTransactionInformation= new QueryLatestTransactionInformation(); |
28 | 28 | |
29 | 29 | $model=new DefinedMeaningModel($definedMeaningId, $filterLanguageId, $possiblySynonymousRelationTypeId, $queryTransactionInformation); |
30 | 30 | $record=$model->getRecord(); |
| 31 | +$record->finish("DefinedMeaning"); |
31 | 32 | echo $record; |
32 | 33 | |
33 | 34 | |
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 @@ |
38 | 38 | break; |
39 | 39 | case "collection-meaning": |
40 | 40 | return new CollectionMeaningHelper($record); |
| 41 | + break; |
41 | 42 | case "goto-source": |
42 | 43 | return new GotoSourceHelper($record); |
| 44 | + break; |
43 | 45 | case "defined-meaning-attributes": |
44 | 46 | return new DefinedMeaningAttributesHelper($record); |
| 47 | + break; |
45 | 48 | default : |
46 | 49 | echo "IGIVEUP ($type) I Give Up! \n"; |
47 | 50 | break; |
— | — | @@ -51,10 +54,19 @@ |
52 | 55 | |
53 | 56 | abstract class Helper { |
54 | 57 | protected $record; |
| 58 | + protected $saved; |
55 | 59 | public function __construct($record) { |
56 | 60 | $this->record=$record; |
57 | 61 | } |
58 | 62 | |
| 63 | + public function isSaved() { |
| 64 | + return $this->saved; |
| 65 | + } |
| 66 | + |
| 67 | + public function setSaved($saved) { |
| 68 | + $this->saved=$saved; |
| 69 | + } |
| 70 | + |
59 | 71 | //public abstract function getSQL(); |
60 | 72 | //public abstract function save(); |
61 | 73 | |