Passed
Branch master (94c840)
by Lucien
02:10
created

FilterTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace TwinDigital\WPTools;
4
5
use WP_UnitTestCase;
6
7
/**
8
 * Class FilterTest
9
 */
10
class FilterTest extends WP_UnitTestCase
11
{
12
13
    /**
14
     * Setup
15
     * @return void
16
     */
17
    public function setUp()
18
    {
19
        parent::setUp();
20
    }
21
22
    /**
23
     * Test filter removal from classes.
24
     *
25
     * @return void
26
     */
27
    public function testRemove()
28
    {
29
        $filter   = 'testfilter';
30
        $class    = Filter::class;
31
        $function = 'remove';
32
        $priority = 10;
33
        $this->assertFalse(
34
            Filter::remove($filter, $class, $function),
35
            'Should not be able te remove a filter that is not added'
36
        );
37
        $filter   = 'testfilter';
38
        $class    = Filter::class;
39
        $function = 'remove';
40
        $priority = 10;
41
        add_filter($filter, [$class, $function], $priority, 0);
42
        $this->assertTrue(
43
            Filter::remove($filter, $class, $function),
44
            'Should be able te remove a filter that is added'
45
        );
46
        add_filter($filter, [$class, 'test'], $priority, 0);
47
        $this->assertFalse(
48
            Filter::remove($filter, $class, $function),
49
            'Should not be able to remove a filter of which the function doesn\'t exist'
50
        );
51
        $this->assertFalse(
52
            Filter::remove($filter, $class, $function),
53
            'Should not be able te remove a filter that is not added'
54
        );
55
    }
56
}
57