File: 013_complexType.t

package info (click to toggle)
libsoap-wsdl-perl 3.004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,600 kB
  • sloc: perl: 8,433; xml: 1,769; java: 19; makefile: 15
file content (47 lines) | stat: -rw-r--r-- 1,544 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl
use Test::More qw(no_plan);
use strict;
use lib 'lib/';
use lib '../lib/';
use lib 't/lib';

use_ok qw(SOAP::WSDL::XSD::Typelib::ComplexType);
use_ok qw( MyComplexType );
# simple type derived from builtin via restriction
my $obj = MyComplexType->new({ MyTestName => 'test' });
ok $obj->isa('SOAP::WSDL::XSD::Typelib::Builtin::anyType')
    , 'inherited class';
is $obj, '<MyTestName>test</MyTestName>', 'stringification';

$obj = MyComplexType->new({ MyTestName => [ 'test', 'test2' ] });
ok $obj->isa('SOAP::WSDL::XSD::Typelib::Builtin::anyType')
    , 'inherited class';
is $obj, '<MyTestName>test</MyTestName><MyTestName>test2</MyTestName>',
    'stringification';

# try on the fly factory
@MyComplexType2::ISA = ('SOAP::WSDL::XSD::Typelib::ComplexType');
{
    use Class::Std::Fast::Storable;
    my %MyTestName_of;

    MyComplexType2->_factory(
        [ qw(MyTestName) ],                # order
        { MyTestName => \%MyTestName_of },  # attribute lookup map
        { MyTestName => 'MyElement' }       # class name lookup map
    );
}

$obj = MyComplexType2->new({ MyTestName => [ 'test', 'test2' ] });
ok $obj->isa('SOAP::WSDL::XSD::Typelib::Builtin::anyType')
    , 'inherited class (on the fly-factory object)';
is $obj, '<MyTestName xmlns="urn:Test">test</MyTestName><MyTestName xmlns="urn:Test">test2</MyTestName>',
    'stringification (on the fly-factory object)';

# TODO factor out into complexType test

eval { $obj->get_ZUMSL };
like $@, qr{Valid\smethods}xm, 'error message (invalid method)';

__END__