2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2010-09-17 09:14:14 -04:00
|
|
|
#
|
|
|
|
# Created by Henrik Mårtensson on 2007-02-18.
|
|
|
|
# Copyright (c) 2007. All rights reserved.
|
|
|
|
|
|
|
|
require "rexml/document"
|
|
|
|
require "test/unit"
|
|
|
|
|
2014-05-27 08:07:40 -04:00
|
|
|
module REXMLTests
|
2014-05-27 09:10:55 -04:00
|
|
|
class TestXmlDeclaration < Test::Unit::TestCase
|
|
|
|
def setup
|
2018-12-19 21:49:10 -05:00
|
|
|
xml = <<-XML
|
2014-05-27 09:10:55 -04:00
|
|
|
<?xml encoding= 'UTF-8' standalone='yes'?>
|
|
|
|
<root>
|
|
|
|
</root>
|
2018-12-19 21:49:10 -05:00
|
|
|
XML
|
2014-05-27 09:10:55 -04:00
|
|
|
@doc = REXML::Document.new xml
|
|
|
|
@root = @doc.root
|
|
|
|
@xml_declaration = @doc.children[0]
|
|
|
|
end
|
2011-05-15 07:55:52 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def test_is_first_child
|
|
|
|
assert_kind_of(REXML::XMLDecl, @xml_declaration)
|
|
|
|
end
|
2011-05-15 07:55:52 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def test_has_document_as_parent
|
|
|
|
assert_kind_of(REXML::Document, @xml_declaration.parent)
|
|
|
|
end
|
2011-05-15 07:55:52 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def test_has_sibling
|
|
|
|
assert_kind_of(REXML::XMLDecl, @root.previous_sibling.previous_sibling)
|
|
|
|
assert_kind_of(REXML::Element, @xml_declaration.next_sibling.next_sibling)
|
|
|
|
end
|
2018-12-19 21:49:10 -05:00
|
|
|
|
|
|
|
def test_write_prologue_quote
|
|
|
|
@doc.context[:prologue_quote] = :quote
|
|
|
|
assert_equal("<?xml version=\"1.0\" " +
|
|
|
|
"encoding=\"UTF-8\" standalone=\"yes\"?>",
|
|
|
|
@xml_declaration.to_s)
|
|
|
|
end
|
2010-09-17 09:14:14 -04:00
|
|
|
end
|
|
|
|
end
|