Code Duplication    Length = 14-15 lines in 2 locations

packages/terms-of-service/tests/php/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

@@ 466-480 (lines=15) @@
463
	 * @return Mock The mock object.
464
	 * @throws MockEnabledException PHPUnit wasn't able to enable mock functions.
465
	 */
466
	protected function mock_function( $function_name, $return_value = null, $namespace = __NAMESPACE__ ) {
467
		$builder = new MockBuilder();
468
		$builder->setNamespace( $namespace )
469
			->setName( $function_name )
470
			->setFunction(
471
				function() use ( &$return_value ) {
472
					return $return_value;
473
				}
474
			);
475
476
		$mock = $builder->build();
477
		$mock->enable();
478
479
		return $mock;
480
	}
481
482
	/**
483
	 * Filter to set the default constant values.