Refactoring Unit Test and PRC vars

Hi folks,

Please see the following GIST: https://gist.github.com/nolandubeau/35ee3a9f0d25d5f4adba

I am refactoring a User handler to use a PRC variable for lookup instead of an RC variable, and am unsure how to refactor my UnitTest to set the PRC variable.

I believe that my issue lines with line 62 of UserTest.cfc. What needs to be changed here?

I also have a second issue with User.cfc where the following is throwing an error when running the test…:

getcoldBoxOCM().get(‘activePartners’)

I’m assuming that this is not mocked correctly?

Any help on the above two issues would be a great help.

Thank you.

Nolan

Off the top of my head I don’t have the answer, but I did notice one thing. In your user.cfc you are referencing the prc.user_id however you are not getting the private context out.

In other words there is no prc = event.getCollection(private = true);

Also if you are using ColdBox 3.1+ you can do this instead of what you have in your user.cfc


	function getUser(event, rc, prc){
		//load user record

		rc.user = userService.getUser(prc.user_id,getcoldBoxOCM().get('activePartners'));

		

Hi Andrew,

I noticed that as well (and fixed it) however it didn’t seem to resolve the problem. I’m using ColdBox 3.6.

Thanks.

Nolan