Esempio n. 1
0
     });
     it('should change the attributes of a node', function () {
         $xml = new FluidXml();
         $xml->appendChild('child', true)->setAttribute('attr1', 'Attr1 Value')->setAttribute('attr2', 'Attr2 Value')->setAttribute('attr2', 'Attr2 New Value');
         $expected = "<doc>\n" . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 New Value\"/>\n" . "</doc>";
         assert_equal_xml($xml, $expected);
         $xml = new FluidXml();
         $xml->appendChild('child', true)->setAttribute(['attr1' => 'Attr1 Value', 'attr2' => 'Attr2 Value'])->setAttribute('attr1', 'Attr1 New Value');
         $expected = "<doc>\n" . "  <child attr1=\"Attr1 New Value\" attr2=\"Attr2 Value\"/>\n" . "</doc>";
         assert_equal_xml($xml, $expected);
     });
 });
 describe('.appendText', function () {
     it('should add text to the root node', function () {
         $xml = new FluidXml();
         $xml->appendText('Document Text First Line');
         $expected = "<doc>Document Text First Line</doc>";
         assert_equal_xml($xml, $expected);
         $xml->appendText('Document Text Second Line');
         $expected = "<doc>Document Text First LineDocument Text Second Line</doc>";
         assert_equal_xml($xml, $expected);
     });
     it('should add text to a node', function () {
         $xml = new FluidXml();
         $cx = $xml->appendChild('p', true);
         $cx->appendText('Document Text First Line');
         $expected = "<doc>\n" . "  <p>Document Text First Line</p>\n" . "</doc>";
         assert_equal_xml($xml, $expected);
         $cx->appendText('Document Text Second Line');
         $expected = "<doc>\n" . "  <p>Document Text First LineDocument Text Second Line</p>\n" . "</doc>";
         assert_equal_xml($xml, $expected);