Ejemplo n.º 1
0
 public function testGrandchild()
 {
     $root = new SXE('<root><child /></root>');
     $new = new SXE('<new />');
     $root->child->appendChild($new);
     $this->assertXmlStringEqualsXmlString($root->asXML(), '<root><child><new /></child></root>');
 }
Ejemplo n.º 2
0
 public function testNoRef()
 {
     $root = new SXE('<root><child /></root>');
     $new = new SXE('<new />');
     $return = $root->insertBefore($new);
     $this->assertXmlStringEqualsXmlString('<root><child /><new /></root>', $root->asXML());
     $this->assertSame(dom_import_simplexml($root->new), dom_import_simplexml($return));
 }
Ejemplo n.º 3
0
 public function testRoot()
 {
     $root = new SXE('<root />');
     $new = new SXE('<new />');
     $expected_result = clone $new;
     $expected_return = clone $root;
     $return = $root->replaceSelf($new);
     $this->assertEquals($root, $expected_result);
     $this->assertEquals($return, $expected_return);
 }
Ejemplo n.º 4
0
 public function testRoot()
 {
     $root = new SXE('<root><child /></root>');
     $parent = $root->parentNode();
     /**
      * When asked for the root node's parent, DOM returns the root node itself
      */
     $this->assertTrue($parent instanceof SXE);
     $this->assertSame(dom_import_simplexml($root), dom_import_simplexml($parent));
 }
Ejemplo n.º 5
0
 /**
  * @expectedException DOMException
  */
 public function testWrongDocument()
 {
     $root = new SXE('<root />');
     $node = new SXE('<node />');
     try {
         $root->removeChild($node);
     } catch (DOMException $e) {
         $this->assertSame(DOM_WRONG_DOCUMENT_ERR, $e->code);
         throw $e;
     }
 }
Ejemplo n.º 6
0
 public function testInvalidArgumentType2()
 {
     $root = new SXE('<root />');
     try {
         $root->addProcessingInstruction('xml-stylesheet', false);
         $fail = true;
     } catch (Exception $e) {
         $fail = false;
     }
     if ($fail) {
         self::fail();
     }
 }
Ejemplo n.º 7
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidXML()
 {
     $root = new SXE('<root><child /></root>');
     $root->appendXML('<bad><xml>');
 }
Ejemplo n.º 8
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidXPath()
 {
     $root = new SXE('<root />');
     $new = new SXE('<new />');
     $root->replaceNodes('????', $new);
 }
Ejemplo n.º 9
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidArgumentType()
 {
     $root = new SXE('<root />');
     $root->getElementById(false);
 }
Ejemplo n.º 10
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidXPath()
 {
     $root = new SXE('<root />');
     $root->deleteNodes('????');
 }
Ejemplo n.º 11
0
 public function testRoot()
 {
     $root = new SXE('<root><child1 /><child2 /><child3 /></root>');
     $this->assertNull($root->nextSibling());
 }
Ejemplo n.º 12
0
 /**
  * @expectedException BadMethodCallException
  */
 public function testRoot()
 {
     $root = new SXE('<root />');
     $new = new SXE('<new />');
     $root->insertBeforeSelf($new);
 }
Ejemplo n.º 13
0
 public function testNoChild()
 {
     $root = new SXE('<root />');
     $this->assertNull($root->lastChild());
 }
Ejemplo n.º 14
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidTagName()
 {
     $root = new SXE('<root />');
     $root->getElementsByTagName('$$$$');
 }
Ejemplo n.º 15
0
 /**
  * @expectedException BadMethodCallException
  */
 public function testRoot()
 {
     $root = new SXE('<root><child /></root>');
     $root->deleteSelf();
 }
Ejemplo n.º 16
0
 /**
  * @expectedException BadMethodCallException
  */
 public function testRoot()
 {
     $root = new SXE('<root />');
     $root->removeSelf();
 }