| @@ 108-119 (lines=12) @@ | ||
| 105 | * |
|
| 106 | * @return phpmock\Mock The mock object. |
|
| 107 | */ |
|
| 108 | protected function mock_function( $function_name, $return_value = null, $called_with = null ) { |
|
| 109 | $builder = new MockBuilder(); |
|
| 110 | $builder->setNamespace( __NAMESPACE__ ) |
|
| 111 | ->setName( $function_name ) |
|
| 112 | ->setFunction( |
|
| 113 | function( $value ) use ( &$return_value, $called_with ) { |
|
| 114 | if ( $called_with ) { |
|
| 115 | $this->assertEquals( $value, $called_with ); |
|
| 116 | } |
|
| 117 | return $return_value; |
|
| 118 | } |
|
| 119 | ); |
|
| 120 | return $builder->build()->enable(); |
|
| 121 | } |
|
| 122 | } |
|
| @@ 377-391 (lines=15) @@ | ||
| 374 | * @return Mock The mock object. |
|
| 375 | * @throws MockEnabledException PHPUnit wasn't able to enable mock functions. |
|
| 376 | */ |
|
| 377 | protected function mock_function( $function_name, $return_value = null, $namespace = __NAMESPACE__ ) { |
|
| 378 | $builder = new MockBuilder(); |
|
| 379 | $builder->setNamespace( $namespace ) |
|
| 380 | ->setName( $function_name ) |
|
| 381 | ->setFunction( |
|
| 382 | function() use ( &$return_value ) { |
|
| 383 | return $return_value; |
|
| 384 | } |
|
| 385 | ); |
|
| 386 | ||
| 387 | $mock = $builder->build(); |
|
| 388 | $mock->enable(); |
|
| 389 | ||
| 390 | return $mock; |
|
| 391 | } |
|
| 392 | ||
| 393 | } |
|
| 394 | ||