I'm trying to run a unit test to see if the case owner upon insertion matches an expected value. In this case, the expected case owner will be the account owner. However, upon inserting the case, the case owner changes to a queue. The queue in this case is our "default" queue, which is configured in the support settings module. I recently deactivated all of the triggers on the case object to see if the owner was changing after insert, but that does not seem to be the issue.
Test.startTest(); CreateTicket obj = new CreateTicket(); Case newCase = obj.createcase(); System.debug('The owner on the new case is a user' + newcase.ownerid); Database.dmloptions dmo = new Database.DMLOPtions(); dmo.assignmentRuleHeader.useDefaultRule = false; newcase.setOptions(dmo); insert newCase; Test.stopTest(); String expectedOwner = 'Expected Owner'; String actualOwner = [SELECT Id, Ownerid FROM Case WHERE Id = :newCase.id LIMIT 1].owner.name System.assertEquals(expectedOwner, actualOwner , 'owners do not match');