Ejemplo n.º 1
0
 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());
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }