[Koha-bugs] [Bug 5327] Unit tests required for all C4 modules

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Aug 13 14:14:50 CEST 2012


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5327

Julian Maurice <julian.maurice at biblibre.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |julian.maurice at biblibre.com

--- Comment #219 from Julian Maurice <julian.maurice at biblibre.com> ---
Hello all,

Jonathan tells me to try DBD::Mock for one of my patch (Bug 5339), which I did.
But I noticed some odd behaviour and I'm wondering if we are using it like we
should.
Example:

# This assume C4::Context::_new_dbh is mocked.

my $rs = [
    ['id', 'column1', ...],
    [1, 'a', ...],
    [2, 'b', ...]
];
my $dbh = C4::Context->dbh;
$dbh->{mock_add_resultset} = $rs;
my @a = my_function();


my_function execute a single 'select' query and return data like in $rs,
but in fact, even if my query is "SELECT * FROM bar WHERE id=1", it returns
all the resultset. And even worse, if my query is something like
"SELECT foo FROM bar", the whole resultset is still returned.

My question is: how can we use DBD::Mock for testing subroutines while
subroutines
will always return what we expect, and not what they should?

Is there something I'm doing wrong or something I don't understand?

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list