# packeta/2.1/tests/Module/MockFactory.php

Packeta, version 2.1. 41 lines.

- Page: https://pluginprobe.com/plugins/packeta/2.1/code/tests/Module/MockFactory.php
- Raw: https://pluginprobe.com/plugins/packeta/2.1/raw/tests/Module/MockFactory.php
- Modified: 2025-03-10T10:47:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/packeta/2.1/code/tests/Module/MockFactory.php#L10-L20`.

```php
<?php

declare( strict_types=1 );

namespace Tests\Module;

use Packetery\Module\Checkout\CurrencySwitcherService;
use Packetery\Module\Framework\WpAdapter;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class MockFactory {
	public static function createWpAdapter( TestCase $testCase ): WpAdapter|MockObject {
		$mock = $testCase->getMockBuilder( WpAdapter::class )->getMock();
		$mock
			->method( 'applyFilters' )
			->willReturnCallback(
				static function ( string $hookName, $value ) {
					return $value;
				}
			);

		return $mock;
	}

	public static function createCurrencySwitcherFacade( TestCase $testCase ): CurrencySwitcherService|MockObject {
		$mock = $testCase->getMockBuilder( CurrencySwitcherService::class )
			->disableOriginalConstructor()
			->getMock();
		$mock
			->method( 'getConvertedPrice' )
			->willReturnCallback(
				static function ( $value ) {
					return $value;
				}
			);

		return $mock;
	}
}

```
