PluginProbe
Packeta / 2.0.3
Packeta v2.0.3
2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 All 55 releases
packeta / tests / Module / MockFactory.php

MockFactory.php in Packeta 2.0.3, at tests/Module/MockFactory.php

41 lines 964 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare( strict_types=1 );
4
5 namespace Tests\Module;
6
7 use Packetery\Module\Checkout\CurrencySwitcherService;
8 use Packetery\Module\Framework\WpAdapter;
9 use PHPUnit\Framework\MockObject\MockObject;
10 use PHPUnit\Framework\TestCase;
11
12 class MockFactory {
13 public static function createWpAdapter( TestCase $testCase ): WpAdapter|MockObject {
14 $mock = $testCase->getMockBuilder( WpAdapter::class )->getMock();
15 $mock
16 ->method( 'applyFilters' )
17 ->willReturnCallback(
18 static function ( string $hookName, $value ) {
19 return $value;
20 }
21 );
22
23 return $mock;
24 }
25
26 public static function createCurrencySwitcherFacade( TestCase $testCase ): CurrencySwitcherService|MockObject {
27 $mock = $testCase->getMockBuilder( CurrencySwitcherService::class )
28 ->disableOriginalConstructor()
29 ->getMock();
30 $mock
31 ->method( 'getConvertedPrice' )
32 ->willReturnCallback(
33 static function ( $value ) {
34 return $value;
35 }
36 );
37
38 return $mock;
39 }
40 }
41