| Total Complexity | 2 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 | ); |
||
| 57 |