Hi All

I have a question about PHPUnit. I want to write a test case for the following Message class and want to cover the default: case in my test cases by passing an invalid $type in the isValidMessageType() method. Just to give you a proper scenario of when this will be useful, suppose the developer adds another type i.e. 3 in the isValidMessageType() method but forgets to add a switch case in the SendMessage() method, in that scenario the default case will throw an exception.


PHP Code:
class Message
{

    public function 
isValidMessageType($type)
    {
        return (
$type == || $type == 2)
    }

    public function 
SendMessage($type)
    {

        if(!
$this->isValidMessageType($type)){
            throw new 
Exception('Invalid Message type');
        }

        switch (
$type) {
            case 
1:
                
// do something
                
break;
            case 
2:
                
// do something
                
break;
            default:
                throw new 
Exception('Invalid Message type');
        }

    }


Can someone please help me how to achieve this?


Thanks in advance