I am trying to populate an object with the results of a query. Testbox fails when I use getters to check the members of my object (see attached TestBox report).
Here is the method I am currently testing:
// Dependency Injection
property name=“dsn” inject=“coldbox:setting:g2g”;
property name=“userSVC” inject=“UserSVC@administration”;
property name=“populator” inject=“wirebox:populator”;
property name=“wirebox” inject=“wirebox”;
property name=“bcrypt” inject="@BCrypt";
function init(){
return this;
}
// These methods are required by the AuthenticateService of the Coldbox cbauth module
public function retrieveUserByUsername(required string username) {
// the username parameter is an e-mail address that uniquely identifies the user for the login process
// This method returns a User object that I need for the Coldbox AuthenticationService component
try {
var q = new Query();
q.setDatasource("#dsn.name#");
q.setMaxRows(1);
q.setSQL("SELECT usrla_login_id,usrla_email_address,usrla_account_screenname, usrla_password, usrla_email_notify
FROM tab_user_accounts
WHERE usrla_email_address = :userLogin
AND usrla_account_status = :userAccountStatus ");
q.addParam(name: “userLogin”, value: “#Trim(arguments.username)#”, cfsqltype: “CF_SQL_VARCHAR”);
q.addParam(name: “userAccountStatus”, value: “0”, cfsqltype: “CF_SQL_TINYINT”);
var qData = q.execute();
} catch (database e) {
// Build the error message and capture it to a variable
var errorMsg = “#e.sqlState#: #e.message# #e.queryError#”;
// Throw the exception and pass the error message variable for the controller to handle
throw(type=“NoMatchingRecord”, message="#errorMsg#");
}
//return qData;
return populator.populateFromQuery(wirebox.getInstance(“User”),qData.getResult());
}
The query executes properly (//return qData). However, when I try to populate the User component, it seems my syntax is incomplete, but I am not sure what TestBox is trying to tell me.
NB: I would like to avoid using queryExecute() for the time being as it may require qb which I do not need at the moment.