use Test::More tests => 11; use lib '../lib'; use File::Basename qw(dirname); use Cwd; my $path = dirname __FILE__; use_ok(qw/SOAP::WSDL::Expat::WSDLParser/); my $filter; my $parser; ok($parser = SOAP::WSDL::Expat::WSDLParser->new() ); eval { $parser->parse_file( "$path/test.wsdl" ) }; if ($@) { fail("parsing WSDL: $@"); die "Can't test without parsed WSDL"; } else { pass("parsing XML"); } my $wsdl; ok( $wsdl = $parser->get_data() , "get object tree"); my $schema = $wsdl->first_types(); my $opt = { readable => 0, autotype => 1, namespace => $wsdl->get_xmlns(), indent => "\t", typelib => $schema, }; is( $schema->find_type( 'urn:myNamespace', 'testSimpleType1' )->serialize( 'test', 1 , $opt ), q{1} , "serialize simple type"); is( $schema->find_type( 'urn:myNamespace', 'testSimpleList' )->serialize( 'testList', [ 1, 2, 3 ] , $opt), q{1 2 3}, "serialize simple list type" ); is( $schema->find_element( 'urn:myNamespace', 'TestElement' )->serialize( undef, 1 , $opt), q{1}, "Serialize element" ); $opt->{ readable } = 0; is( $schema->find_type( 'urn:myNamespace', 'length3')->serialize( 'TestComplex', { size => -13, unit => 'BLA' } , $opt ), q{} . q{-13} . q{BLA} , "serialize complex type" ); is( $schema->find_element( 'urn:myNamespace', 'TestElementComplexType')->serialize( undef, { size => -13, unit => 'BLA' } , $opt ), q{} . q{-13} . q{BLA}, "element with complex type" ); is( $schema->find_type( 'urn:myNamespace', 'complex')->serialize( 'complexComplex', { 'length' => { size => -13, unit => 'BLA' }, 'int' => 1 }, $opt ), q{} . q{} . q{-13} . q{BLA} . q{1}, "nested complex type" ); is( $wsdl->find_message('urn:myNamespace', 'testRequest')->first_part()->serialize( undef, { test => { length => { size => -13, unit => 'BLA' } , int => 3 } }, $opt ), q{} . q{} . q{-13} . q{BLA} . q{3} , "Message part" );