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

PluginTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A test_plugin_is_loaded() 0 8 1
A test_action_loaded() 0 5 1
A test_filter_loaded() 0 4 1
A test_settings_link_is_present() 0 7 1
A test_option_page_is_loaded() 0 14 1
1
<?php
2
/**
3
 * @package wpmautic\tests
4
 */
5
6
/**
7
 * Test generic plugin behaviour
8
 */
9
class PluginTest 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 test_plugin_is_loaded()
12
    {
13
        $active = get_option( 'active_plugins', array() );
14
        $this->assertContains('mautic-wordpress/wpmautic.php', $active);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<PluginTest>.

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...
15
16
        $this->assertTrue(function_exists('wpmautic_option'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PluginTest>.

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...
17
        $this->assertTrue(function_exists('wpmautic_inject_script'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PluginTest>.

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...
18
    }
19
20
    public function test_action_loaded()
21
    {
22
        $this->assertTrue(false !== has_action('admin_menu', 'wpmautic_settings'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PluginTest>.

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->assertTrue(false !== has_action('plugins_loaded', 'wpmautic_injector'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PluginTest>.

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_filter_loaded()
27
    {
28
        $this->assertTrue(false !== has_filter('plugin_action_links', 'wpmautic_plugin_actions'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<PluginTest>.

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...
29
    }
30
31
    public function test_settings_link_is_present()
32
    {
33
        $links = apply_filters('plugin_action_links', array(), 'mautic-wordpress/wpmautic.php');
34
35
        $this->assertCount(1, $links);
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<PluginTest>.

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...
36
        $this->assertContains('options-general.php?page=wpmautic', $links[0]);
0 ignored issues
show
Bug introduced by
The method assertContains() does not seem to exist on object<PluginTest>.

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...
37
    }
38
39
    public function test_option_page_is_loaded()
40
    {
41
        $current_user = get_current_user_id();
42
        wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
0 ignored issues
show
Bug introduced by
The method factory() does not seem to exist on object<PluginTest>.

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
        $this->assertEmpty(menu_page_url('wpmautic', false));
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<PluginTest>.

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...
45
        wpmautic_settings();
46
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PluginTest>.

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
            admin_url( 'options-general.php?page=wpmautic' ),
48
            menu_page_url('wpmautic', false)
49
        );
50
51
        wp_set_current_user( $current_user );
52
    }
53
}
54