{
my
$this
= {
this
=>
'thing'
};
my
$that
= {
that
=>
'thing'
};
my
$theOther
= {
other
=>
'thing'
};
no
warnings
qw{redefine once}
;
local
*TestRail::API::_doRequest
=
sub
{
return
$this
};
my
$tr
=
bless
({},
'TestRail::API'
);
is_deeply(
$tr
->getCaseFields(),
$this
,
"getCaseFields appears to operate correctly on initial hit"
);
no
warnings
qw{redefine once}
;
local
*TestRail::API::_doRequest
=
sub
{
my
(
$self
,
$url
,
$method
,
$input
) =
@_
;
return
$that
unless
$method
;
return
$input
};
is_deeply(
$tr
->getCaseFields(),
$this
,
"getCaseFields caches correctly"
);
is_deeply(
$tr
->addCaseField(
%$theOther
),
$theOther
,
"addCaseField appears to grab and pass options correctly"
);
is_deeply(
$tr
->getCaseFields(),
$that
,
"getCaseFields invalidates cache correctly"
);
}