samedi 9 décembre 2017

PHPUnit testing method that contains function that needs to be mocked

Hello im testing a method which uses this function, that is not in any class. It needs to be as it is without the class because this is in wordpress. I need to mock this function, i declared it twice once it will return true and second time it will return false, but it gave me an error with redeclaration. What should i do to mock this method twice?

function wcs_order_contains_subscription() {
    return false;
}
//testing stuff
function wcs_order_contains_subscription() {
    return true;
}
//test another stuff

Aucun commentaire:

Enregistrer un commentaire