Diff of /trunk/t/SOAP/Serializer.t [r418] .. [r419]  Maximize  Restore

Switch to unified view

a/trunk/t/SOAP/Serializer.t b/trunk/t/SOAP/Serializer.t
1
use strict;
1
use strict;
2
use warnings;
2
use warnings;
3
use Test::More tests => 3; #qw(no_plan);
3
use Test::More tests => 13; #qw(no_plan);
4
4
5
use_ok qw(SOAP::Serializer);
5
use_ok qw(SOAP::Lite);
6
6
7
my $obj = SOAP::Serializer->new();
7
my $serializer = SOAP::Serializer->new();
8
8
9
is $obj->find_prefix('http://schemas.xmlsoap.org/soap/envelope/'), 'soap';
9
is $serializer->find_prefix('http://schemas.xmlsoap.org/soap/envelope/'), 'soap';
10
10
11
like $obj->envelope('method' => SOAP::Data->name('test')),
11
ok my $tag = $serializer->tag('fooxml', {}), 'serialize <fooxml/>';
12
    qr{ <test\s*/> }xms,
12
ok $tag = $serializer->tag('_xml', {}), 'serialize <_xml/>';
13
    'Empty method call does not use xsi:nil="true"';
13
eval {
14
    $tag = $serializer->tag('---', {});
15
};
16
like $@, qr{^Element \s '---' \s can't \s be \s allowed}x, 'error on <xml:lang/>';
17
undef $@;
18
eval {
19
  local $SIG{__WARN__} = sub {
20
      like $_[0], qr{^Element \s 'xmlfoo'}x;
21
  };
22
23
    $tag = $serializer->tag('xmlfoo', {});
24
};
25
26
27
my $xml = $serializer->envelope('fault', faultstring => '>>> foo <<<');
28
like $xml, qr{\&gt;\&gt;\&gt;}x, 'fault escaped OK';
29
unlike $xml, qr{\&amp;gt;}x, 'fault escaped OK';
30
31
$xml = $serializer->envelope('response', foo => '>>> bar <<<');
32
like $xml, qr{\&gt;\&gt;\&gt;}x, 'response escaped OK';
33
unlike $xml, qr{\&amp;gt;}x, 'response escaped OK';
34
35
$xml = $serializer->envelope('method', foo => '>>> bar <<<');
36
like $xml, qr{\&gt;\&gt;\&gt;}x, 'response escaped OK';
37
unlike $xml, qr{\&amp;gt;}x, 'response escaped OK';
38
39
40
SKIP: {
41
    eval "require Test::Differences"
42
        or skip 'Cannot test without Test::Differences', 1;
43
44
    my $serializer = SOAP::Serializer->new()->autotype(1);
45
46
    my @som_data = ( SOAP::Data->name('Spec'), SOAP::Data->name('Version')
47
    );
48
    my $complex_data =  SOAP::Data->name( 'complex' )
49
        ->attr( { attr => '123' } )
50
        ->value( [ SOAP::Data->name('Spec'), SOAP::Data->name('Version') ]
51
    );
52
    my $result = $serializer->encode_object($complex_data, 'test', undef, {});
53
54
    # remove attributes created by autotype
55
    delete $result->[1]->{'soapenc:arrayType'};
56
    delete $result->[1]->{'xsi:type'};
57
58
    # turn off autotyping
59
    $serializer->autotype(0);
60
61
    # now we are able to compare both kinds of serialization
62
    Test::Differences::eq_or_diff( $result,
63
                $serializer->encode_object($complex_data, 'test', undef, {}),
64
                'autotype off array serialization');
65
}