Code Duplication    Length = 14-15 lines in 2 locations

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.

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

@@ 93-106 (lines=14) @@
90
	 *
91
	 * @return phpmock\Mock The mock object.
92
	 */
93
	protected function mock_function( $function_name, $return_value = null, $called_with = null ) {
94
		$builder = new MockBuilder();
95
		$builder->setNamespace( __NAMESPACE__ )
96
				->setName( $function_name )
97
				->setFunction(
98
					function ( $value ) use ( &$return_value, $called_with ) {
99
						if ( $called_with ) {
100
							$this->assertEquals( $value, $called_with );
101
						}
102
						return $return_value;
103
					}
104
				);
105
		return $builder->build()->enable();
106
	}
107
}
108