Skip to content

Commit

Permalink
Wrap helper callback in an autoloaded wrapper to keep namespace clean
Browse files Browse the repository at this point in the history
  • Loading branch information
epdenouden authored and sebastianbergmann committed Dec 24, 2018
1 parent 3f9ef97 commit d0e22b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions tests/_files/FunctionCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
function functionCallback()
class FunctionCallbackWrapper
{
$args = \func_get_args();
public static function functionCallback()
{
$args = \func_get_args();

if ($args == ['foo', 'bar']) {
return 'pass';
if ($args == ['foo', 'bar']) {
return 'pass';
}
}
}
4 changes: 2 additions & 2 deletions tests/unit/Framework/MockObject/MockObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function testFunctionCallback(): void

$mock->expects($this->once())
->method('doSomething')
->will($this->returnCallback('functionCallback'));
->will($this->returnCallback('FunctionCallbackWrapper::functionCallback'));

$this->assertEquals('pass', $mock->doSomething('foo', 'bar'));

Expand All @@ -282,7 +282,7 @@ public function testFunctionCallback(): void

$mock->expects($this->once())
->method('doSomething')
->willReturnCallback('functionCallback');
->willReturnCallback('FunctionCallbackWrapper::functionCallback');

$this->assertEquals('pass', $mock->doSomething('foo', 'bar'));
}
Expand Down

0 comments on commit d0e22b0

Please sign in to comment.