Test::Mock::LWP(3pm)

πŸ“¦
version 0.08 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Test::Mock::LWP πŸ’–

okay so bestie, welcome to Test::Mock::LWP β€” it's the User Contributed Perl Documentation's little gift to you, and it's literally about making mocking LWP packages easy. no cap. πŸ¦‹


✨ NAME ✨

Test::Mock::LWP β€” Easy mocking of LWP packages πŸ’…


🌸 SYNOPSIS 🌸

Make LWP packages to make testing easier. that's the whole vibe, fr fr.

use Test::Mock::LWP;

# Setup fake response content and code
$Mock_response->mock( content => sub { 'foo' } );
$Mock_resp->mock( code => sub { 201 } );

# Validate args passed to request constructor
is_deeply $Mock_request->new_args, \@expected_args;

# Validate request headers
is_deeply [ $Mock_req->next_call ],
          [ 'header', [ 'Accept', 'text/plain' ] ];

# Special User Agent Behaviour
$Mock_ua->mock( request => sub { die 'foo' } );

look at that. iconic. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

So the tea is: this package exists because the author kept duplicating the same code to mock LWP et al in several different modules he'd written. like, copy-paste city. πŸ™ˆ This version is very minimalist, but it works for his needs so far β€” and he is very open to new suggestions and improvements. so if you got ideas, he wants them. 🫢


🌈 EXPORTS 🌈

The following variables are exported by default:

  • $Mock_ua β€” the mock LWP::UserAgent object, which is a Test::MockObject object. main character energy tbh.
  • $Mock_req, $Mock_request β€” the mock HTTP::Request object, which is a Test::MockObject object. two names, one icon. πŸ’œ
  • $Mock_resp, $Mock_response β€” the mock HTTP::Response object, which is a Test::MockObject object. also serving double-name realness. πŸŽ€

πŸ’œ AUTHOR πŸ’œ

Luke Closs, "<test-mock-lwp at 5thplane.com>" β€” we stan. πŸ‘‘


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mock-LWP>.

he'll be notified, and then you'll automatically be notified of progress on your bug as he makes changes. mutual notif bestie behaviour. πŸ””

🧚 SUPPORT 🧚

You can find documentation for this module with the perldoc command. it's giving self-serve:

perldoc Test::Mock::LWP

You can also look for information at:


πŸ“ ACKNOWLEDGEMENTS πŸ“

(ngl this section is empty in the original β€” nothing listed here, so nothing for me to hype up. πŸ™ˆ)


Copyright 2006 Luke Closs, all rights reserved. ✨

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


okay that's the whole page, and for the sign-off: this was perl v5.34.0, dated 2022-06-28, and it lives under the name Test::Mock::LWP(3pm). go mock some LWP, bestie β€” periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from