2018-01-22 14:25:37 +00:00
|
|
|
<?php
|
|
|
|
|
2019-10-06 22:23:15 +00:00
|
|
|
use PHPUnit\Framework\MockObject\Invocation;
|
|
|
|
use PHPUnit\Framework\MockObject\Invocation\StaticInvocation;
|
2019-12-09 11:02:40 +00:00
|
|
|
use PHPUnit\Framework\MockObject\Stub\Stub;
|
2019-10-06 22:23:15 +00:00
|
|
|
|
2019-12-09 11:02:40 +00:00
|
|
|
class EchoExecuteFirstArgumentStub implements Stub {
|
2019-10-06 22:23:15 +00:00
|
|
|
public function invoke( Invocation $invocation ) {
|
|
|
|
if ( !$invocation instanceof StaticInvocation ) {
|
|
|
|
throw new PHPUnit\Framework\Exception( 'wrong invocation type' );
|
2018-01-22 14:25:37 +00:00
|
|
|
}
|
|
|
|
if ( !$invocation->arguments ) {
|
2019-10-06 22:23:15 +00:00
|
|
|
throw new PHPUnit\Framework\Exception( 'Method call must have an argument' );
|
2018-01-22 14:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return call_user_func( reset( $invocation->arguments ) );
|
|
|
|
}
|
|
|
|
|
2021-07-23 21:23:16 +00:00
|
|
|
public function toString(): string {
|
2018-01-22 14:25:37 +00:00
|
|
|
return 'return result of call_user_func on first invocation argument';
|
|
|
|
}
|
|
|
|
}
|