1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package wpmautic\tests |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Test Mautic options management |
8
|
|
|
*/ |
9
|
|
|
class OptionsTest extends WP_UnitTestCase |
|
|
|
|
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @expectedException InvalidArgumentException |
13
|
|
|
*/ |
14
|
|
|
public function test_invalid_option_name() |
15
|
|
|
{ |
16
|
|
|
wpmautic_option('azerty123456'); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function test_base_url_when_empty() |
20
|
|
|
{ |
21
|
|
|
update_option('wpmautic_options', array( |
22
|
|
|
'base_url' => '' |
23
|
|
|
)); |
24
|
|
|
$this->assertEmpty(wpmautic_option('base_url')); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function test_base_url_with_value() |
28
|
|
|
{ |
29
|
|
|
update_option('wpmautic_options', array( |
30
|
|
|
'base_url' => 'http://example.com' |
31
|
|
|
)); |
32
|
|
|
$this->assertEquals('http://example.com', wpmautic_option('base_url')); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function test_script_location_when_empty() |
36
|
|
|
{ |
37
|
|
|
update_option('wpmautic_options', array()); |
38
|
|
|
$this->assertEquals('header', wpmautic_option('script_location')); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function test_script_location_with_value() |
42
|
|
|
{ |
43
|
|
|
update_option('wpmautic_options', array( |
44
|
|
|
'script_location' => 'footer' |
45
|
|
|
)); |
46
|
|
|
$this->assertEquals('footer', wpmautic_option('script_location')); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function test_fallback_activated_when_empty() |
50
|
|
|
{ |
51
|
|
|
update_option('wpmautic_options', array()); |
52
|
|
|
$this->assertTrue(wpmautic_option('fallback_activated')); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function test_fallback_activated_with_value() |
56
|
|
|
{ |
57
|
|
|
update_option('wpmautic_options', array( |
58
|
|
|
'fallback_activated' => false |
59
|
|
|
)); |
60
|
|
|
$this->assertFalse(wpmautic_option('fallback_activated')); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.