Test Failed
Branch master (4a30b9)
by John
02:00
created

OptionsTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A test_invalid_option_name() 0 4 1
A test_base_url_when_empty() 0 7 1
A test_base_url_with_value() 0 7 1
A test_script_location_when_empty() 0 5 1
A test_script_location_with_value() 0 7 1
A test_fallback_activated_when_empty() 0 5 1
A test_fallback_activated_with_value() 0 7 1
1
<?php
2
/**
3
 * @package wpmautic\tests
4
 */
5
6
/**
7
 * Test Mautic options management
8
 */
9
class OptionsTest extends WP_UnitTestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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'));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<OptionsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OptionsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OptionsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<OptionsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
    }
48
49
    public function test_fallback_activated_when_empty()
50
    {
51
        update_option('wpmautic_options', array());
52
        $this->assertTrue(wpmautic_option('fallback_activated'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<OptionsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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'));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<OptionsTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
    }
62
}
63