@depends flag breaks the arguments in my PHPUnit function
In the code below, testFunctionA outputs true, while testFunctionB outputs nu开发者_如何学运维ll. Is this a known error and can I get around it without getting rid of my @depends flags?
public function testFunctionA( $x = true ) {
var_dump( $x ); // outputs true
}
/*
* @depends testFunctionA
*/
public function testFunctionB( $y = true ) {
var_dump( $y ); // outputs NULL
}
The @depends annotation does a bit more than you are thinking it does here. Mainly, the return value from testFunctionA is passed into testFunctionB. Since testFunctionA doesn't return anything, testFunctionB is getting passed a null value.
See the PHPUnit test dependencies docs for more information.
There is a difference between providing a null parameter and no parameter at all to testFunctionB. Only with nothing provided will $y default to true.
精彩评论