annotationsphpunitdocblocks

Mocking docblock annotations in PHPUnit


I am building an app that implements custom docblock annotations using the Doctrine Annotations library.

For PHPUnit testing, is it possible to create a mocked class that has mock docblocks?

From this answer, I learned how to mock a class, like so:

$foo = $this->getMockBuilder('nonexistant')
    ->setMockClassName('TestClass')
    ->getMock();

Is there a way to mock a docblock? Building on the class example, Something like this is what I imagine:

$foo = $this->getMockBuilder('nonexistant')
    ->setMockClassName('TestClass')
    ->setMockClassDocblock('/** @SomeAnnotation("foo") */')
    ->getMock();

If not - is there anything I can do besides just creating actual test classes?


Solution

  • There is no way to mock a docblock. If you can make the case that there should be then please open a ticket.