/**
|
* This class contains unit tests for validating the behavior of Apex classes
|
* and triggers.
|
*
|
* Unit tests are class methods that verify whether a particular piece
|
* of code is working properly. Unit test methods take no arguments,
|
* commit no data to the database, and are flagged with the testMethod
|
* keyword in the method definition.
|
*
|
* All test methods in an organization are executed whenever Apex code is deployed
|
* to a production organization to confirm correctness, ensure code
|
* coverage, and prevent regressions. All Apex classes are
|
* required to have at least 75% code coverage in order to be deployed
|
* to a production organization. In addition, all triggers must have some code coverage.
|
*
|
* The @isTest class annotation indicates this class only contains test
|
* methods. Classes defined with the @isTest annotation do not count against
|
* the organization size limit for all Apex scripts.
|
*
|
* See the Apex Language Reference for more information about Testing and Code Coverage.
|
*/
|
@isTest
|
private class PeCommentListControllerTest {
|
|
static testMethod void myUnitTest() {
|
PersonalEvaluation__c pe1 = new PersonalEvaluation__c(
|
RecordTypeId = '01210000000RDuV',
|
ReportName__c = 'userReport',
|
Comment__c = 'comment1',
|
OwnerId = UserInfo.getUserId()
|
);
|
PersonalEvaluation__c pe2 = new PersonalEvaluation__c(
|
RecordTypeId = '01210000000RDuV',
|
ReportName__c = 'provinceReport',
|
Comment__c = 'comment2',
|
Province__c = '北京市;上海市',
|
OwnerId = UserInfo.getUserId()
|
);
|
PersonalEvaluation__c pe3 = new PersonalEvaluation__c(
|
RecordTypeId = '01210000000RDua',
|
TabName__c = 'userTab',
|
Comment__c = 'comment3',
|
OwnerId = UserInfo.getUserId()
|
);
|
PersonalEvaluation__c pe4 = new PersonalEvaluation__c(
|
RecordTypeId = '01210000000RDua',
|
TabName__c = 'provinceTab',
|
Comment__c = 'comment4',
|
Province__c = '北京市;上海市',
|
OwnerId = UserInfo.getUserId()
|
);
|
insert new PersonalEvaluation__c[] {pe1, pe2, pe3, pe4};
|
|
PageReference page = new PageReference('/apex/PersonalEvaluationCommentList?user=' + UserInfo.getUserId() + '&rpt=userReport');
|
System.Test.setCurrentPage(page);
|
PersonalEvaluationCommentListController pec = new PersonalEvaluationCommentListController();
|
List<PersonalEvaluation__c> rtn = pec.getCommentList();
|
System.assertEquals('comment1', rtn[0].Comment__c);
|
|
page = new PageReference('/apex/PersonalEvaluationCommentList?province=' + EncodingUtil.urlEncode('北京市,四川省', 'UTF-8') + '&rpt=provinceReport');
|
System.Test.setCurrentPage(page);
|
pec = new PersonalEvaluationCommentListController();
|
rtn = pec.getCommentList();
|
System.assertEquals('comment2', rtn[0].Comment__c);
|
|
page = new PageReference('/apex/PersonalEvaluationCommentList?user=' + UserInfo.getUserId() + '&tab=userTab');
|
System.Test.setCurrentPage(page);
|
pec = new PersonalEvaluationCommentListController();
|
rtn = pec.getCommentList();
|
System.assertEquals('comment3', rtn[0].Comment__c);
|
|
page = new PageReference('/apex/PersonalEvaluationCommentList?province=' + EncodingUtil.urlEncode('北京市,四川省', 'UTF-8') + '&tab=provinceTab');
|
System.Test.setCurrentPage(page);
|
pec = new PersonalEvaluationCommentListController();
|
rtn = pec.getCommentList();
|
System.assertEquals('comment4', rtn[0].Comment__c);
|
}
|
}
|