Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User testUser = new User(stuff goes here);
- testUser.UserPermissionsKnowledgeUser = true;
- System.runAs (testUser) {
- //this works fine
- system.debug( [select id, KnowledgeArticleId from internal__kav where PublishStatus= 'Draft' AND Language = 'en_US' limit 1]);
- }
- global class testbatchimplements Database.Batchable<sObject>{
- global Database.QueryLocator start(Database.BatchableContext BC){
- return Database.getQueryLocator([select id, KnowledgeArticleId from internal__kav where PublishStatus= 'Draft' AND Language = 'en_US']);
- }
- global void execute(Database.BatchableContext BC, List<sObject> scope){}
- global void finish(Database.BatchableContext BC){}
- }
- User testUser = new User(stuff goes here);
- testUser.UserPermissionsKnowledgeUser = true;
- System.runAs (testUser) {
- //this works fine
- Test.startTest();
- database.executeBatch(new testbatch());
- Test.stopTest();
- }
- global class testScheduled implements Schedulable {
- global void execute(SchedulableContext SC){
- Database.executeBatch(new testBatch());
- }
- }
- User testUser = new User(stuff goes here);
- testUser.UserPermissionsKnowledgeUser = true;
- System.runAs (testUser) {
- // fails
- Test.startTest();
- String cron = '0 0 * * * ?';
- System.schedule('test',cron, new testScheduled());
- Test.stopTest();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement