function testHandleRecordTransclusion()
 {
     global $wgParser;
     global $wgDataTransclusionSources;
     $data[] = array("name" => "foo", "id" => "3", "info" => 'test&X');
     $spec = array('class' => 'FakeDataTransclusionSource', 'data' => $data, 'keyFields' => 'name,id', 'fieldNames' => 'id,name,info', 'defaultKey' => 'id');
     $wgDataTransclusionSources['FOO'] = $spec;
     # failure mode: no source given
     $s = DataTransclusionHandler::handleRecordTransclusion("Dummy", array('foo' => 'bar', 'id' => 3), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-missing-source"/', $s) === 1);
     # failure mode: bad source given
     $s = DataTransclusionHandler::handleRecordTransclusion("Dummy", array('source' => '*** nonsense ***', 'id' => 3), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-unknown-source"/', $s) === 1);
     # failure mode: bad source given (alternative)
     $s = DataTransclusionHandler::handleRecordTransclusion("Dummy", array(1 => '*** nonsense ***', 'id' => 3), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-unknown-source"/', $s) === 1);
     # failure mode: no key value specified
     $s = DataTransclusionHandler::handleRecordTransclusion("Dummy", array('source' => 'FOO'), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-missing-key"/', $s) === 1);
     # failure mode: no template specified
     $s = DataTransclusionHandler::handleRecordTransclusion(null, array('source' => 'FOO', 'id' => 3), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-missing-argument-template"/', $s) === 1);
     # failure mode: illegal template specified
     $s = DataTransclusionHandler::handleRecordTransclusion("##", array('source' => 'FOO', 'id' => 3), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-bad-template-name"/', $s) === 1);
     # failure mode: record can't be found for that key
     $s = DataTransclusionHandler::handleRecordTransclusion("Dummy", array('source' => 'FOO', 'id' => 'xxxxxxxxxx'), $wgParser, false);
     $this->assertTrue(preg_match('/class="error datatransclusion-record-not-found"/', $s) === 1);
     /*
     //TODO: re-enable this once DataTransclusionHandler::render() detects missing templates again.
     # failure mode: unknown template
     $s = DataTransclusionHandler::handleRecordTransclusion( "3", array( 'source' => 'FOO', 'template' => '---SomeTemplateThatHopefullyDoesNotExist---' ), $wgParser, false );
     $this->assertTrue( preg_match( '/class="error datatransclusion-unknown-template"/', $s ) === 1 );
     */
     ////////////////////////////////////////////////////////
     # success: render record
     $res = DataTransclusionHandler::handleRecordTransclusion("Test", array('source' => 'FOO', 'id' => 3), $wgParser, false, "'''{{{id}}}'''|{{{name}}}|{{{info}}}");
     $this->assertEquals('\'\'\'3\'\'\'|foo|test&X', $res);
     # success: render record (find by name)
     $res = DataTransclusionHandler::handleRecordTransclusion("Test", array('source' => 'FOO', 'name' => 'foo'), $wgParser, false, "'''{{{id}}}'''|{{{name}}}|{{{info}}}");
     $this->assertEquals('\'\'\'3\'\'\'|foo|test&X', $res);
     # success: render record (as HTML)
     $res = DataTransclusionHandler::handleRecordTransclusion("Test", array('source' => 'FOO', 'id' => 3), $wgParser, true, "'''{{{id}}}'''|{{{name}}}|{{{info}}}");
     $this->assertEquals($res, '<b>3</b>|foo|test&X');
     // FIXME: & should have been escaped to &amp; here, no? why not?
 }
 /**
  * Entry point for the <record> tag parser hook. Delegates to handleRecordTransclusion.
  */
 static function handleRecordTag($text, $argv, $parser)
 {
     return DataTransclusionHandler::handleRecordTransclusion($text, $argv, $parser, true);
 }