6 use MediaWikiCoversValidator;
7 use Wikimedia\TestingAccessWrapper;
14 use MediaWikiCoversValidator;
18 ->setMethods( [
'execute',
'output' ] )
20 $benchProxy = TestingAccessWrapper::newFromObject( $bench );
21 $benchProxy->defaultCount = 3;
25 'test' =>
function ()
use ( &$count ) {
30 $this->assertSame( 3, $count );
35 ->setMethods( [
'execute',
'output' ] )
37 $benchProxy = TestingAccessWrapper::newFromObject( $bench );
38 $benchProxy->defaultCount = 2;
52 $this->assertSame( [
'setup',
'run',
'run' ],
$buffer );
57 ->setMethods( [
'execute',
'output',
'hasOption',
'verboseRun' ] )
59 $benchProxy = TestingAccessWrapper::newFromObject( $bench );
60 $benchProxy->defaultCount = 1;
62 $bench->expects( $this->exactly( 2 ) )->method(
'hasOption' )
63 ->will( $this->returnValueMap( [
68 $bench->expects( $this->once() )->method(
'verboseRun' )
73 'test' =>
function () {
83 ->setMethods( [
'execute',
'output',
'addResult' ] )
85 $benchProxy = TestingAccessWrapper::newFromObject( $bench );
86 $benchProxy->defaultCount = 1;
88 $bench->expects( $this->once() )->method(
'addResult' )
89 ->with( $this->callback(
function (
$res ) {
90 return isset(
$res[
'name'] ) &&
$res[
'name'] === __CLASS__ .
'::noop()';
94 [
'function' => [ $this,
'noop' ] ]
100 ->setMethods( [
'execute',
'output',
'addResult' ] )
102 $benchProxy = TestingAccessWrapper::newFromObject( $bench );
103 $benchProxy->defaultCount = 1;
105 $bench->expects( $this->once() )->method(
'addResult' )
106 ->with( $this->callback(
function (
$res ) {
107 return 'strtolower(A)';
111 'function' =>
'strtolower',
121 ->setMethods( [
'execute',
'output',
'hasOption',
'startBench',
'addResult' ] )
123 $benchProxy = TestingAccessWrapper::newFromObject( $bench );
124 $benchProxy->defaultCount = 1;
126 $bench->expects( $this->exactly( 2 ) )->method(
'hasOption' )
127 ->will( $this->returnValueMap( [
132 $bench->expects( $this->once() )->method(
'output' )
133 ->with( $this->callback(
function (
$out ) {
134 return preg_match(
'/memory.+ peak/',
$out ) === 1;
138 'test' =>
function () {