Update (Fixed): After looking at PHPUnit: stub methods undefined I fixed the issue. When using namespaces, getMock() needs the fully qualified namespace of the class being mocked.
I updated the code to:
namespace Test\Library;
class MockClassTest extends \PHPUnit_Framework_TestCase
{
public $test;
public function setUp() {
$this->test = $this->getMock('Test\Library\TestMockClass');
}
public function testMock() {
$this->test->expects($this->any())
->method('test')
->will($this->returnValue(null));
$this->assertEquals(null, $this->test->test());
}
}
and the test runs fine.