Unit testing 如何获得作为引用传递的结果,而不返回PHPUnit方法的类型?

Unit testing 如何获得作为引用传递的结果,而不返回PHPUnit方法的类型?,unit-testing,phpunit,pass-by-reference,Unit Testing,Phpunit,Pass By Reference,我试图从phpunit调用xyz方法,它是受保护的方法,并且没有返回类型 protected function xyz(&$data) { $data = preg_replace('/^abc_88$/i', '88', $data); } 我打算在单元测试中调用上述方法,它看起来像: public function testXyz() { $data = 'abc_88'; $order = $this->createMock('cl

我试图从phpunit调用xyz方法,它是受保护的方法,并且没有返回类型

protected function xyz(&$data)
{
    $data = preg_replace('/^abc_88$/i', '88', $data);
        
}
我打算在单元测试中调用上述方法,它看起来像:

public function testXyz()
{
    $data = 'abc_88';
    $order = $this->createMock('className');
    $result = $this->invokeMethod(
                         $order, 'xyz', $data
                    );
    $this->assertEquals('88', $result);
}
我希望该断言在phpunit testXyz()中成功。 但不改变xyz()

注意:不应使用退货类型。