/** * @requires PHP 7.0 * @expectedException \Error * @expectedExceptionMessageRegExp /Call to protected method.+from context/ */ public function testProtectedMethodCall() { $this->expectOutputRegex('/Call to protected method.+from context/'); $obj = new SimpleClass(); $obj->protectedMethod(); }