public function testSimple() { $object = new \stdClass(); $callback = new fXSLCallback("test:only"); $this->assertEquals("test:only", $callback->getNamespace()); $callback->setObject($object); $this->assertEquals($object, $callback->getObject()); }
public function testTransform() { $tpl = new \DOMDocument(); $tpl->load(__DIR__ . '/_data/test.xsl'); $dom = new \DOMDocument(); $xsl = new fXSLTProcessor($tpl); $xsl->registerPHPFunctions("TheSeer\\fXSL\\fxsltprocessorTest::demo"); $test = new fXSLCallback('test:only', 'test'); $test->setObject($this); $xsl->registerCallback($test); $result = $xsl->transformToXml($dom); $testDoc = new \DOMDocument(); $testDoc->loadXML($result); $testXPath = new \DOMXPath($testDoc); $demos = $testXPath->evaluate("/root/demo"); /* @var $demos \DOMNodeList */ $this->assertEquals(1, $demos->length); $this->assertEquals(self::demo(), $demos->item(0)->textContent); $roots = $testXPath->evaluate("/root/test/root"); /* @var $roots \DOMNodeList */ $this->assertEquals(1, $roots->length); $this->assertEquals($this->bar('hallo', 'welt')->textContent, $roots->item(0)->textContent); }
/** * Register an fXSLCallback object instance * * @param fXSLCallback $callback The instance of the fXSLCallback to register */ public function registerCallback(fXSLCallback $callback) { $this->initDone = FALSE; if (!$this->registered) { $this->registerPHPFunctions(); } if (!isset(self::$registry[$this->hash])) { self::$registry[$this->hash] = array(); } self::$registry[$this->hash][$callback->getNamespace()] = $callback; }