$property() Method
any $property(string propertyName, [string propertyScope='variables'], any mock)//decorate our user service with mocking capabilities, just to show a different approach
userService = getMockBox().prepareMock( createObject("component","model.UserService") );
//create a mock dao and mock the getUsers() method
mockDAO=getMockBox().createEmptyMock("model.UserDAO").$("getUsers",QueryNew(""));
//Inject it as a property of the user service, since no external injections are found. variables scope is the default.
userService.$property(propertyName="userDAO",mock=mockDAO);
//Test a user service method that uses the DAO
results = userService.getUsers();
assertTrue( isQuery(results) );Was this helpful?