mediawiki-extensions-Echo/tests/phpunit/mapper/EchoExecuteFirstArgumentStub.php
Daimona Eaytoy c256faf968 Remove hack for PHPUnit's Stub interface
This partly reverts commit c19c88567b.

Bug: T192167
Depends-On: Ia12658554c94497a204b7f65f1a6f7b1fa0310ac
Change-Id: I4ef736d87d05f74920ce88f57b0ad824986adb26
2020-01-23 12:34:48 +00:00

23 lines
691 B
PHP

<?php
use PHPUnit\Framework\MockObject\Invocation;
use PHPUnit\Framework\MockObject\Invocation\StaticInvocation;
use PHPUnit\Framework\MockObject\Stub\Stub;
class EchoExecuteFirstArgumentStub implements Stub {
public function invoke( Invocation $invocation ) {
if ( !$invocation instanceof StaticInvocation ) {
throw new PHPUnit\Framework\Exception( 'wrong invocation type' );
}
if ( !$invocation->arguments ) {
throw new PHPUnit\Framework\Exception( 'Method call must have an argument' );
}
return call_user_func( reset( $invocation->arguments ) );
}
public function toString() : string {
return 'return result of call_user_func on first invocation argument';
}
}