2018-01-22 14:25:37 +00:00
|
|
|
<?php
|
2019-11-18 13:30:26 +00:00
|
|
|
// @codingStandardsIgnoreStart
|
2018-01-22 14:25:37 +00:00
|
|
|
|
2019-10-06 22:23:15 +00:00
|
|
|
use PHPUnit\Framework\MockObject\Invocation;
|
|
|
|
use PHPUnit\Framework\MockObject\Invocation\StaticInvocation;
|
|
|
|
|
2019-11-18 13:30:26 +00:00
|
|
|
if ( !interface_exists( PHPUnit\Framework\MockObject\Stub\Stub::class ) ) {
|
|
|
|
// PHPUnit < 8
|
|
|
|
interface StubCompatTemp extends PHPUnit\Framework\MockObject\Stub {
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// PHPUnit 8+
|
|
|
|
interface StubCompatTemp extends PHPUnit\Framework\MockObject\Stub\Stub {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EchoExecuteFirstArgumentStub implements StubCompatTemp {
|
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 ) );
|
|
|
|
}
|
|
|
|
|
2019-11-18 13:30:26 +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';
|
|
|
|
}
|
|
|
|
}
|
2019-11-18 13:30:26 +00:00
|
|
|
// @codingStandardsIgnoreEnd
|