_verifyRequestTypeId =>_lookupRequestTypeById
I found need to have _verifyRequestTypeId() actually return the request_type in a reimplementation of getRequest() that I'm working on, so I've made this change. Some tests are failing because of the use of _verifyRequestTypeId(). Next commit will address that.
This commit is contained in:
parent
b03a469338
commit
10030b3488
2 changed files with 19 additions and 15 deletions
|
@ -910,7 +910,7 @@ sub _verifyId($$) {
|
|||
|
||||
}
|
||||
|
||||
=item _verifyRequestTypeId()
|
||||
=item _lookupRequestTypeById()
|
||||
|
||||
Parameters:
|
||||
|
||||
|
@ -923,22 +923,26 @@ Parameters:
|
|||
|
||||
=back
|
||||
|
||||
Returns: scalar boolean, which is true iff. the $requestTypeId is valid and
|
||||
Returns: scalar, which is the request_type found iff. the C<$requestTypeId> is valid and
|
||||
already in the supporter database's request_type table.
|
||||
|
||||
Die if the C<$requestTypeId> isn't a number.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub _verifyRequestTypeId($$) {
|
||||
sub _lookupRequestTypeById($$) {
|
||||
my($self, $requestTypeId) = @_;
|
||||
|
||||
die "_verifyRequestTypeId() called with a non-numeric id" unless defined $requestTypeId and looks_like_number($requestTypeId);
|
||||
|
||||
my $val = $self->dbh()->selectall_hashref("SELECT id FROM request_type WHERE id = " .
|
||||
my $val = $self->dbh()->selectall_hashref("SELECT id, type FROM request_type WHERE id = " .
|
||||
$self->dbh->quote($requestTypeId, 'SQL_INTEGER'), 'id');
|
||||
return (defined $val and defined $val->{$requestTypeId});
|
||||
|
||||
if (defined $val and defined $val->{$requestTypeId}) {
|
||||
return $val->{$requestTypeId}{type};
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
=item _getOrCreateRequestType
|
||||
|
|
|
@ -532,20 +532,20 @@ lives_ok { $tempSP->_getOrCreateRequestType(\%hh); }
|
|||
is_deeply(\%hh, { requestTypeId => $rr },
|
||||
"_getOrCreateRequestType: deletes requestType if both are provided.");
|
||||
|
||||
dies_ok { $tempSP->_verifyRequestTypeId(undef); }
|
||||
"_verifyRequestTypeId: dies for undefined requestTypeId";
|
||||
dies_ok { $tempSP->_lookupRequestTypeById(undef); }
|
||||
"_lookupRequestTypeById: dies for undefined requestTypeId";
|
||||
|
||||
dies_ok { $tempSP->_verifyRequestTypeId("NoStringsPlease"); }
|
||||
"_verifyRequestTypeId: dies for a string requestTypeId";
|
||||
dies_ok { $tempSP->_lookupRequestTypeById("NoStringsPlease"); }
|
||||
"_lookupRequestTypeById: dies for a string requestTypeId";
|
||||
|
||||
ok( (not $tempSP->_verifyRequestTypeId(0)), "_verifyRequestTypeId: returns false for id lookup for 0");
|
||||
ok( (not $tempSP->_lookupRequestTypeById(0)), "_lookupRequestTypeById: returns false for id lookup for 0");
|
||||
|
||||
# Assumption here: that id number one more than the last added would never be in db.
|
||||
ok( (not $tempSP->_verifyRequestTypeId($rr + 1)),
|
||||
"_verifyRequestTypeId: returns false for id one greater than last added");
|
||||
ok( (not $tempSP->_lookupRequestTypeById($rr + 1)),
|
||||
"_lookupRequestTypeById: returns false for id one greater than last added");
|
||||
|
||||
ok( ($tempSP->_verifyRequestTypeId($rr)),
|
||||
"_verifyRequestTypeId: returns true for id known to be in database");
|
||||
is($tempSP->_lookupRequestTypeById($rr), "test-request",
|
||||
"_lookupRequestTypeById: returns proper result for id known to be in database");
|
||||
|
||||
|
||||
=item _getOrCreateRequestConfiguration
|
||||
|
|
Loading…
Reference in a new issue