Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 125 lines (105 sloc) 3.772 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
--TEST--
XML_Util2::createStartElement() basic tests
--CREDITS--
Chuck Burgess <ashnazg@php.net>
# created for v1.2.0a1 2008-05-04
--FILE--
<?php
require_once 'XML' . DIRECTORY_SEPARATOR . 'Util2.php';
$util = new XML_Util2();
echo '=====XML_Util2::createStartElement() basic tests=====' . PHP_EOL . PHP_EOL;

echo "TEST: tag only" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag"
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar")
) . PHP_EOL . PHP_EOL;

echo "TEST: tag only, passing '' as attribute arg" . PHP_EOL;
echo $util->createStartElement(
    'myNs:myTag',
    ''
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes and namespace" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar"),
    "http://www.w3c.org/myNs#"
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with empty attributes, whose namespaceUri is not a full namespace" . PHP_EOL;
echo $util->createStartElement(
    'myTag',
    '',
    'foo'
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes, namespace, and multiline = true" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar"),
    "http://www.w3c.org/myNs#",
    true
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar"),
    "http://www.w3c.org/myNs#",
    true,
    ' '
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar"),
    "http://www.w3c.org/myNs#",
    true,
    ' ',
    '^'
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar", "boo" => "baz"),
    "http://www.w3c.org/myNs#",
    true,
    ' ',
    '^',
    true
) . PHP_EOL . PHP_EOL;

echo "TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false" . PHP_EOL;
echo $util->createStartElement(
    "myNs:myTag",
    array("foo" => "bar", "boo" => "baz"),
    "http://www.w3c.org/myNs#",
    true,
    ' ',
    '^',
    false
) . PHP_EOL . PHP_EOL;
?>
--EXPECT--
=====XML_Util2::createStartElement() basic tests=====

TEST: tag only
<myNs:myTag>

TEST: tag with attributes
<myNs:myTag foo="bar">

TEST: tag only, passing '' as attribute arg
<myNs:myTag>

TEST: tag with attributes and namespace
<myNs:myTag foo="bar" xmlns:myNs="http://www.w3c.org/myNs#">

TEST: tag with empty attributes, whose namespaceUri is not a full namespace
<myTag xmlns="foo">

TEST: tag with attributes, namespace, and multiline = true
<myNs:myTag foo="bar"
xmlns:myNs="http://www.w3c.org/myNs#">

TEST: tag with attributes, namespace, multiline = true, and indent = (2 spaces only)
<myNs:myTag foo="bar"
xmlns:myNs="http://www.w3c.org/myNs#">

TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), and linebreak = '^'
<myNs:myTag foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">

TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = true
<myNs:myTag boo="baz"^ foo="bar"^ xmlns:myNs="http://www.w3c.org/myNs#">

TEST: tag with attributes, namespace, multiline = true, indent = (2 spaces only), linebreak = '^', and sortAttributes = false
<myNs:myTag foo="bar"^ boo="baz"^ xmlns:myNs="http://www.w3c.org/myNs#">
Something went wrong with that request. Please try again.