salesforce - Apex Access Specifiers and Test Classes -


I'm seeing some behavior in the Wolfssey's Apex code that I do not understand. This code seems to break security rules I have a controller that looks something like this:

  Sharing class with CaseController public {// property public case TheCase {get; Private set; } // // Constructor Public Case Controller (APXPage.Standard Controller Controller) {// Some Unimportant Goods} // // Coming from all the data and making the case public PageReference save () {// Some others Unimportant stuff}}   

and a test that looks like this:

  Clear Private Static Testing Method Save_WithCompleteCase_SavesCase () {// User User = GetTestUser ('Standard Users'); Product 2 product = GetTestProduct (); Episode theCase = GetTestCase (user, theProduct); System.runAs (user) {// When the Cases Controller Controller = New Case Controller (New Apex Page. Standard Controller (theCase)); Controller Case Sperm = 'test case'; // Make a change to test it PageReference page = controller.Save (); // then}}   

Note that my controller has a personal setter on "TheCase", yet I am able to change its value in the test class. This code works and it is processed by SalesForce. Why? Is there anything special about examinations classes that allow them to reach the private members of other classes?

Thank you!

Duh, was not thinking clearly before. Setter case is private on property, but property of the case, such as the topic, is still publicly accessible

Setting the case property private only prevents the controller from changing the case from under it.

Sorry!

Comments