Code Duplication    Length = 12-15 lines in 2 locations

packages/terms-of-service/tests/php/test_TermsOfService.php 1 location

@@ 85-96 (lines=12) @@
82
	 * @param mixed  $return_value  Return value of the function.
83
	 * @return phpmock\Mock The mock object.
84
	 */
85
	protected function mock_function( $function_name, $return_value = null, $called_with = null ) {
86
		$builder = new MockBuilder();
87
		$builder->setNamespace( __NAMESPACE__ )
88
				->setName( $function_name )
89
				->setFunction( function( $VALUE ) use ( &$return_value, $called_with ) {
90
					if ( $called_with ) {
91
						$this->assertEquals( $VALUE, $called_with );
92
					}
93
					return $return_value;
94
				} );
95
		return $builder->build()->enable();
96
	}
97
}
98

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

@@ 270-284 (lines=15) @@
267
	 * @return Mock The mock object.
268
	 * @throws MockEnabledException PHPUnit wasn't able to enable mock functions.
269
	 */
270
	protected function mock_function( $function_name, $return_value = null ) {
271
		$builder = new MockBuilder();
272
		$builder->setNamespace( __NAMESPACE__ )
273
			->setName( $function_name )
274
			->setFunction(
275
				function() use ( &$return_value ) {
276
					return $return_value;
277
				}
278
			);
279
280
		$mock = $builder->build();
281
		$mock->enable();
282
283
		return $mock;
284
	}
285
286
}
287