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

SettingsTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package wpmautic\tests
4
 */
5
6
/**
7
 * Test mautic settings page
8
 */
9
class SettingsTest 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
    public function setUp()
12
    {
13
        parent::setUp();
14
        require_once(VPMAUTIC_PLUGIN_DIR.'/options.php');
15
16
        $this->setOutputCallback(create_function('', ''));
0 ignored issues
show
Bug introduced by
The method setOutputCallback() does not seem to exist on object<SettingsTest>.

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...
Security Best Practice introduced by
The use of create_function is highly discouraged, better use a closure.

create_function can pose a great security vulnerability as it is similar to eval, and could be used for arbitrary code execution. We highly recommend to use a closure instead.

// Instead of
$function = create_function('$a, $b', 'return $a + $b');

// Better use
$function = function($a, $b) { return $a + $b; }
Loading history...
17
    }
18
19
    public function test_nonce_fields_are_present()
20
    {
21
        wpmautic_options_page();
22
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
23
        $this->assertContains("name='option_page' value='wpmautic'", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
24
    }
25
26
    public function test_with_admin_init()
27
    {
28
        wpmautic_admin_init();
29
        wpmautic_options_page();
30
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
31
        $this->assertContains("name='option_page' value='wpmautic'", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
32
        $this->test_base_url_setting();
33
        $this->test_script_location_setting();
34
    }
35
36
    public function test_base_url_setting()
37
    {
38
        wpmautic_base_url();
39
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
40
        $this->assertContains("wpmautic_base_url", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
41
        $this->assertContains("wpmautic_options[base_url]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
42
        $this->assertContains("value=\"\"", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
43
    }
44
45 View Code Duplication
    public function test_base_url_setting_with_value()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
    {
47
        update_option('wpmautic_options', array(
48
            'base_url' => 'http://example.com'
49
        ));
50
51
        wpmautic_base_url();
52
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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
        $this->assertContains("wpmautic_base_url", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
54
        $this->assertContains("wpmautic_options[base_url]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
55
        $this->assertContains("value=\"http://example.com\"", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
56
    }
57
58
    public function test_script_location_setting()
59
    {
60
        wpmautic_script_location();
61
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
62
        $this->assertContains("wpmautic_script_location", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
63
        $this->assertContains("wpmautic_options[script_location]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
64
        $this->assertRegExp('/value="header"\s+checked/', $output);
0 ignored issues
show
Bug introduced by
The method assertRegExp() does not seem to exist on object<SettingsTest>.

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...
65
    }
66
67 View Code Duplication
    public function test_script_location_setting_with_footer_checked()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
    {
69
        update_option('wpmautic_options', array(
70
            'script_location' => 'footer'
71
        ));
72
73
        wpmautic_script_location();
74
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
75
        $this->assertContains("wpmautic_script_location", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
76
        $this->assertContains("wpmautic_options[script_location]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
77
        $this->assertRegExp('/value="footer"\s+checked/', $output);
0 ignored issues
show
Bug introduced by
The method assertRegExp() does not seem to exist on object<SettingsTest>.

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...
78
    }
79
80
    public function test_fallback_activated_setting_with_default()
81
    {
82
        wpmautic_fallback_activated();
83
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
84
        $this->assertContains("wpmautic_fallback_activated", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
85
        $this->assertContains("wpmautic_options[fallback_activated]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
86
        $this->assertContains("checked", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
87
    }
88
89 View Code Duplication
    public function test_fallback_activated_setting_with_unchecked()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        update_option('wpmautic_options', array(
92
            'fallback_activated' => false
93
        ));
94
95
        wpmautic_fallback_activated();
96
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
97
        $this->assertContains("wpmautic_fallback_activated", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
98
        $this->assertContains("wpmautic_options[fallback_activated]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
99
        $this->assertNotContains("checked", $output);
0 ignored issues
show
Bug introduced by
The method assertNotContains() does not seem to exist on object<SettingsTest>.

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...
100
    }
101
102 View Code Duplication
    public function test_fallback_activated_setting_with_checked()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
103
    {
104
        update_option('wpmautic_options', array(
105
            'fallback_activated' => true
106
        ));
107
108
        wpmautic_fallback_activated();
109
        $output = $this->getActualOutput();
0 ignored issues
show
Bug introduced by
The method getActualOutput() does not seem to exist on object<SettingsTest>.

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...
110
        $this->assertContains("wpmautic_fallback_activated", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
111
        $this->assertContains("wpmautic_options[fallback_activated]", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
112
        $this->assertContains("checked", $output);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<SettingsTest>.

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...
113
    }
114
}
115