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

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