Code Duplication    Length = 14-15 lines in 2 locations

packages/terms-of-service/tests/php/class-test-terms-of-service.php 1 location

@@ 108-121 (lines=14) @@
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
}
123

packages/connection/tests/php/test_Manager.php 1 location

@@ 326-340 (lines=15) @@
323
	 * @return Mock The mock object.
324
	 * @throws MockEnabledException PHPUnit wasn't able to enable mock functions.
325
	 */
326
	protected function mock_function( $function_name, $return_value = null ) {
327
		$builder = new MockBuilder();
328
		$builder->setNamespace( __NAMESPACE__ )
329
			->setName( $function_name )
330
			->setFunction(
331
				function() use ( &$return_value ) {
332
					return $return_value;
333
				}
334
			);
335
336
		$mock = $builder->build();
337
		$mock->enable();
338
339
		return $mock;
340
	}
341
342
}
343