@@ 25-43 (lines=19) @@ | ||
22 | Mock::disableAll(); |
|
23 | } |
|
24 | ||
25 | function test_affiliate_code_missing() { |
|
26 | $this->mock_function_with_args( 'get_option', [ |
|
27 | [ |
|
28 | 'jetpack_affiliate_code', |
|
29 | '', |
|
30 | '' |
|
31 | ] |
|
32 | ] ); |
|
33 | ||
34 | $this->mock_function_with_args( 'apply_filters', [ |
|
35 | [ |
|
36 | 'jetpack_affiliate_code', |
|
37 | get_option( 'jetpack_affiliate_code', '' ), |
|
38 | get_option( 'jetpack_affiliate_code', '' ) |
|
39 | ] |
|
40 | ] ); |
|
41 | ||
42 | $this->assertEmpty( Affiliate::init()->get_affiliate_code() ); |
|
43 | } |
|
44 | ||
45 | function test_affiliate_code_exists() { |
|
46 | $this->mock_function_with_args( 'get_option', [ |
|
@@ 45-63 (lines=19) @@ | ||
42 | $this->assertEmpty( Affiliate::init()->get_affiliate_code() ); |
|
43 | } |
|
44 | ||
45 | function test_affiliate_code_exists() { |
|
46 | $this->mock_function_with_args( 'get_option', [ |
|
47 | [ |
|
48 | 'jetpack_affiliate_code', |
|
49 | '', |
|
50 | $this->aff_code |
|
51 | ] |
|
52 | ] ); |
|
53 | ||
54 | $this->mock_function_with_args( 'apply_filters', [ |
|
55 | [ |
|
56 | 'jetpack_affiliate_code', |
|
57 | get_option( 'jetpack_affiliate_code', '' ), |
|
58 | get_option( 'jetpack_affiliate_code', '' ) |
|
59 | ] |
|
60 | ] ); |
|
61 | ||
62 | $this->assertEquals( 'abc123', Affiliate::init()->get_affiliate_code() ); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * Mock a global function with particular arguments and make it return a certain value. |