Test::Mock::Two(3)

πŸ“¦ version 0.011, in alpine 3.24

🌸 NAME 🌸

okay bestie, welcome to the Test::Mock::Two(3) page β€” it's giving User Contributed Perl Documentation main character energy, and we're obsessed. πŸ’–

Test::Mock::Two - Inspection module for Test::Mock::One

✨ VERSION ✨

version 0.011 β€” yes ma'am, that's the version. πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

use Test::Mock::One;
use Test::Mock::Two qw(:all);
use Test::Deep;

my $mock = Test::Mock::One->new(
    'X-Mock-Called' => 1,
);

# Do things in your testsuite

# You may omit the test message, it defaults to a sane value
one_called_ok($mock, 'foo', 'Pkg::Foo::bar', "'foo' called by Pkg::Foo::bar");
one_called_times_ok($mock, 'foo', 'Pkg::Foo::bar', 1, "'foo' called once by Pkg::Foo::bar");

# Check if the arguments are correct
# one_called_ok and one_called_times_ok return the same values
my $rv = one_called_times_ok($mock, 'foo', "Pkg::Foo::bar", 1);
cmp_deeply($rv->[0], [], "Called without arguments");

$rv = one_called_ok($mock, 'foo', "Pkg::Foo::bar");
cmp_deeply($rv->[0], [], "Called without arguments");

πŸŽ€ DESCRIPTION πŸŽ€

So like, this module does the introspection of the Test::Mock::One object. The whole point is to keep Test::Mock::One as empty as possible, implementing as little as possible additional methods. It's giving minimalism, fr fr β€” and honestly? Slay. πŸ’…

🌈 EXPORTS 🌈

This module exports nothing by default, and has two export tags:

  • all β€” All functions
  • test β€” All test functions (everything ending with _ok)

πŸ‘‘ METHODS πŸ‘‘

πŸ’œ one_called πŸ’œ

one_called($mock, 'mock_method', "Pkg::Name::method");

Checks if "Pkg::Name::method" called $mock->mock_method.

🫢 one_called_ok 🫢

A Test::Builder enabled version of one_called.

🌟 one_called_times_ok 🌟

one_called($mock, 'mock_method, "Pkg::Name::method", $times);

Tests whether the mock object was called so many times for a given function.

πŸ‘€ SEE ALSO πŸ‘€

Ngl bestie, this section is empty in the original β€” no SEE ALSO refs listed. 🫢

🌸 AUTHOR 🌸

Wesley Schwengle <waterkip@cpan.org>

This software is Copyright (c) 2017 by Wesley Schwengle.

This is free software, licensed under:

The (three-clause) BSD License

And that's the whole page, bestie β€” brought to you by perl v5.42.2, dated 2023-10-04, and signed off by Test::Mock::Two(3). Stay slay, keep testing, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from