File: Element.t

package info (click to toggle)
libsoap-wsdl-perl 3.003-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,860 kB
  • sloc: perl: 8,431; xml: 1,769; java: 19; makefile: 15
file content (54 lines) | stat: -rw-r--r-- 1,806 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
48
49
50
51
52
53
54
package Foo;
sub serialize {
    $_[2] = q{} if not defined $_[2];
    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;