Files
SOAP-WSDL/t/SOAP/WSDL/XSD/Element.t
Martin Kutter f0b3bdc201 import SOAP-WSDL 2.00_31 from CPAN
git-cpan-module:   SOAP-WSDL
git-cpan-version:  2.00_31
git-cpan-authorid: MKUTTER
git-cpan-file:     authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_31.tar.gz
2009-12-12 19:48:21 -08:00

53 lines
1.7 KiB
Perl

package Foo;
sub serialize {
return "serialized $_[1] $_[2]" . join ' ', @{$_[3]->{ attributes } || [] } if $_[3];
}
package main;
use strict;
use warnings;
use Test::More tests => 16;
use_ok qw(SOAP::WSDL::XSD::Element);
my $element = SOAP::WSDL::XSD::Element->new();
is $element->first_simpleType(), undef;
$element->set_simpleType('Foo');
is $element->first_simpleType(), 'Foo';
is $element->serialize('Foobar', 'Bar', { namespace => {} } ), 'serialized Foobar Bar';
is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar ';
$element->set_simpleType( [ 'Foo', 'Bar' ]);
is $element->first_simpleType(), 'Foo';
is $element->first_complexType(), undef;
$element->set_complexType('Foo');
is $element->first_complexType(), 'Foo';
$element->set_complexType( [ 'Foo', 'Bar' ]);
is $element->first_complexType(), 'Foo';
$element->set_default('Foo');
is $element->serialize('Foobar', undef, { namespace => {} } ), 'serialized Foobar Foo';
$element->set_targetNamespace('urn:foobar');
is $element->serialize('Foobar', undef, { namespace => {}, qualify => 1 } ), 'serialized Foobar Foo xmlns="urn:foobar"';
$element->set_targetNamespace('urn:foobar');
is $element->serialize('Foobar', 'Bar', { namespace => {}, qualify => 1 } ), 'serialized Foobar Bar xmlns="urn:foobar"';
$element->set_name('Bar');
is $element->serialize(undef, undef, { namespace => {} } ), 'serialized Bar Foo';
$element->set_fixed('Foobar');
is $element->serialize(undef, undef, { namespace => {} } ), 'serialized Bar Foobar';
$element->set_abstract('1');
is $element->serialize('Bar', undef, { namespace => {} } ), 'serialized Bar Foobar';
eval { $element->serialize(undef, undef, { namespace => {} } ) };
like $@, qr{cannot \s serialize \s abstract}xms;