import SOAP-WSDL 2.00_27 from CPAN
git-cpan-module: SOAP-WSDL git-cpan-version: 2.00_27 git-cpan-authorid: MKUTTER git-cpan-file: authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_27.tar.gz
This commit is contained in:
1 parent
3cfeebae54
commit
eb096ad88e
67 files changed
+1147
-277
No files matched your search
@@ -0,0 +1,11 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 2; #qw(no_plan);
|
||||
|
||||
use_ok qw(SOAP::WSDL::XSD::ComplexType);
|
||||
|
||||
my $obj = SOAP::WSDL::XSD::ComplexType->new();
|
||||
$obj->set_flavor('extension');
|
||||
|
||||
eval { $obj->serialize('foo') };
|
||||
like $@, qr{sorry, \s we \s just}xsm;
|
||||
@@ -0,0 +1,43 @@
|
||||
package Foo;
|
||||
sub serialize {
|
||||
return "serialized $_[1] $_[2]";
|
||||
}
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 12;
|
||||
|
||||
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';
|
||||
|
||||
$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_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;
|
||||
@@ -0,0 +1,33 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 11;
|
||||
|
||||
use_ok qw(SOAP::WSDL::XSD::SimpleType);
|
||||
|
||||
my $obj = SOAP::WSDL::XSD::SimpleType->new();
|
||||
|
||||
$obj->set_list({ LocalName => 'foo', Value => 'bar'},
|
||||
{ LocalName => 'itemType', Value => 'xsd:int'} );
|
||||
is $obj->get_flavor(), 'list';
|
||||
is $obj->get_itemType(), 'xsd:int';
|
||||
|
||||
is $obj->serialize('Foo', ['Foo', 'Bar']), '<Foo>Foo Bar</Foo>';
|
||||
|
||||
$obj->set_union({ LocalName => 'foo', Value => 'bar'},
|
||||
{ LocalName => 'memberTypes', Value => 'xsd:int'} );
|
||||
is $obj->get_flavor(), 'union';
|
||||
is $obj->get_base()->[0], 'xsd:int';
|
||||
|
||||
$obj->set_union({ LocalName => 'foo', Value => 'bar'},
|
||||
{ LocalName => 'memberTypes', Value => 'xsd:int xsd:string'} );
|
||||
is $obj->get_flavor(), 'union';
|
||||
is $obj->get_base()->[1], 'xsd:string';
|
||||
|
||||
is $obj->serialize('Foo', 'Foobar'), '<Foo>Foobar</Foo>';
|
||||
|
||||
$obj->set_flavor('enumeration');
|
||||
is $obj->serialize('Foo', 'Foobar'), '<Foo>Foobar</Foo>';
|
||||
|
||||
# TODO die on non-serializable content...
|
||||
$obj->set_flavor('');
|
||||
is $obj->serialize('Foo', 'Foobar'), '';
|
||||
@@ -1,6 +1,14 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
package MyEmptyType;
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
__PACKAGE__->_factory([],{},{});
|
||||
|
||||
package MyEmptyType2;
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
__PACKAGE__->_factory();
|
||||
|
||||
package MyType;
|
||||
|
||||
use base qw(SOAP::WSDL::XSD::Typelib::ComplexType);
|
||||
@@ -34,15 +42,34 @@ __PACKAGE__->_factory(
|
||||
);
|
||||
|
||||
package main;
|
||||
use Test::More tests => 89;
|
||||
use Data::Dumper;
|
||||
use Test::More tests => 100;
|
||||
use Storable;
|
||||
|
||||
my $have_warn = eval { use Test::Warn; 1; };
|
||||
|
||||
my $obj;
|
||||
|
||||
$obj = MyEmptyType->new();
|
||||
is $obj->serialize, '';
|
||||
is $obj->serialize({ name => 'test'}), '<test />';
|
||||
|
||||
$obj = MyEmptyType2->new();
|
||||
is $obj->serialize, '';
|
||||
is $obj->serialize({ name => 'test'}), '<test />';
|
||||
|
||||
|
||||
$obj = MyType->new({});
|
||||
isa_ok $obj, 'MyType';
|
||||
is $obj->get_test, undef, 'undefined element content';
|
||||
|
||||
my $hash_of_ref = $obj->as_hash_ref();
|
||||
is scalar keys %{ $hash_of_ref }, 0;
|
||||
|
||||
SKIP: {
|
||||
skip 'Cannot test warnings without Test::Warn', 1 if not $have_warn;
|
||||
warning_is { $obj->add_test() } 'attempting to add empty value to MyType';
|
||||
}
|
||||
|
||||
$obj = MyType->new({ test => 'Test1'});
|
||||
isa_ok $obj, 'MyType';
|
||||
isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string';
|
||||
@@ -64,6 +91,9 @@ isa_ok $obj, 'MyType';
|
||||
isa_ok $obj->get_test, 'SOAP::WSDL::XSD::Typelib::Builtin::string';
|
||||
is $obj->get_test, 'Test2', 'element content';
|
||||
|
||||
$hash_of_ref = $obj->as_hash_ref();
|
||||
is $hash_of_ref->{ test }, 'Test2';
|
||||
|
||||
$obj = MyType->new({
|
||||
test => [
|
||||
SOAP::WSDL::XSD::Typelib::Builtin::string->new({
|
||||
@@ -80,6 +110,10 @@ isa_ok $obj->get_test, 'ARRAY';
|
||||
is $obj->get_test()->[0], 'Test', 'element content (list content [0])';
|
||||
is $obj->get_test()->[1], 'Test2', 'element content (list content [1])';
|
||||
|
||||
$hash_of_ref = $obj->as_hash_ref();
|
||||
is $hash_of_ref->{ test }->[0], 'Test';
|
||||
is $hash_of_ref->{ test }->[1], 'Test2';
|
||||
|
||||
my $nested = MyType2->new({
|
||||
test => $obj,
|
||||
});
|
||||
@@ -106,6 +140,10 @@ $nested = MyType2->new({
|
||||
});
|
||||
|
||||
|
||||
$hash_of_ref = $nested->as_hash_ref();
|
||||
is $hash_of_ref->{ test }->{ test }->[1], 'Test2';
|
||||
|
||||
|
||||
# isnt $nested->get_test->[0], $obj, 'element identity';
|
||||
|
||||
$obj = MyType->new();
|
||||
@@ -203,6 +241,14 @@ eval {
|
||||
like $@, qr{cannot \s use \s CODE}xms;
|
||||
|
||||
|
||||
eval {
|
||||
$obj = MyType->new({
|
||||
foobar => 'fubar'
|
||||
});
|
||||
};
|
||||
like $@, qr{unknown \s field \s foobar \s in \s MyType }xms;
|
||||
|
||||
|
||||
eval { $obj->set_FOO(42) };
|
||||
like $@, qr{Can't \s locate \s object \s method}x;
|
||||
|
||||
|
||||
Reference in new issue
Block a user