I'm trying to use Test::Mock::Object with SOAP::Lite, and I'm getting nowhere quick.
I first tried Test::Mock::LWP:
The above with a SOAP::Lite call() produce the following error:
This error comes from line 3642 of Lite.pm:
Going a little deeper, I found this in the output from Dumper of the soap object when called:
This is giving me an indication of why the error is occurring... but I don't know how to begin to fix that w/o
trying to mock SOAP::Lite itself.
Trying to mock SOAP::Lite with Test::Mock::Object has proven unsuccessful so far...
I could continue with all my failed attempts at this... but its just been a stab in the dark as far as creating a decent test environment for SOAP.
Any thoughts/suggestions would greatly be appreciated!
I first tried Test::Mock::LWP:
Code:
use Test::Mock::LWP;
BEGIN {
$Mock_response->mock( content => sub { return SOAP::SOM->new('<foo>bar</foo>'); } );
$Mock_ua->set_isa('LWP::UserAgent');
$Mock_ua->set_true('agent','options','endpoint');
$Mock_ua->mock( http_request => sub { return HTTP::Response->new(200, '200 OK'); } );
};
The above with a SOAP::Lite call() produce the following error:
Code:
A service address has not been specified either by using SOAP::Lite->proxy() or a service description
This error comes from line 3642 of Lite.pm:
Code:
die "A service address has not been specified either by using SOAP::Lite->proxy() or a service description)\n"
unless defined $self->proxy && UNIVERSAL::isa($self->proxy => 'SOAP::Client');
Going a little deeper, I found this in the output from Dumper of the soap object when called:
Code:
'_transport' => bless( {
'_proxy' => bless( {}, 'Test::MockObject' )
}, 'SOAP::Transport' ),
This is giving me an indication of why the error is occurring... but I don't know how to begin to fix that w/o
trying to mock SOAP::Lite itself.
Trying to mock SOAP::Lite with Test::Mock::Object has proven unsuccessful so far...
I could continue with all my failed attempts at this... but its just been a stab in the dark as far as creating a decent test environment for SOAP.
Any thoughts/suggestions would greatly be appreciated!