Last active
December 27, 2015 02:29
-
-
Save greenstork/7253022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class FutureTest { | |
@future | |
public static void createAccountFuture() { | |
Account a = new Account(Name='Test Account'); | |
//User with the standard Read Only profile should not be able to insert an account | |
insert a; | |
} | |
///////////////TESTS//////////////////// | |
static testMethod void testFutureCall() { | |
Profile p = [SELECT id FROM Profile WHERE Name ='Read Only' LIMIT 1]; | |
user u = new User(alias = 'person', email='guest@testpkg.com', | |
emailencodingkey='UTF-8', firstname='Test', lastname='Person', languagelocalekey='en_US', | |
localesidkey='en_US', profileid = p.id, | |
timezonesidkey='America/Los_Angeles', username='guest@testpkg.com'); | |
insert u; | |
Test.startTest(); | |
system.runAs(u) { | |
FutureTest.createAccountFuture(); | |
} | |
Test.stopTest(); | |
Account[] createdAcounts = [SELECT id FROM Account WHERE Name = 'Test Account']; | |
system.assert(createdAcounts.size() == 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment