创建一个MyException的模拟

This is the method that i want to test:

class a {
    public function method($args) {
        if($args == "xxx") {
            throw new MyException("Right Message");
        }
    }

The problem is that Myexception.php is not available, so i should create a mock of MyException and redifine the exception, this is my solution but doesn't work. thanks

/**
     * @expectedException InvalidArgumentException
     * @expectedExceptionMessage Right Message     
     */
     public function testSubscribeCommunity(){
        $MyException = $this->getMockBuilder('MyException')
                ->setMethods(array('__construct'))
                ->setConstructorArgs(array('Right Message'))
                ->disableOriginalConstructor()
                ->getMock();
        $MyException->method('__construct')
                ->will($this->throwException(new InvalidArgumentException));
        $objectToTest = new A();        
        $objectToTest->method(null,$args);
    }

When you mock an object, you create a single special instance of it, but you don't make that the next instances of the class created using "new" become mocked. So in your test the exception being thrown is a real MyException one.