Skip to content

Commit f51531a

Browse files
committed
Tests added
1 parent 50c6801 commit f51531a

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

includes/MslsCustomFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public static function init() {
4141
* Echo's select tag with list of blogs
4242
* @uses selected
4343
*/
44-
public function add_filter() {
44+
public function add_filter(): void {
4545
$id = (
46-
filter_has_var( INPUT_GET, 'msls_filter' ) ?
46+
filter_has_var( INPUT_GET, 'msls_filter' ) ?
4747
filter_input( INPUT_GET, 'msls_filter', FILTER_SANITIZE_NUMBER_INT ) :
4848
''
4949
);

patchwork.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"redefinable-internals": ["filter_input_array"]}
1+
{"redefinable-internals": ["filter_input_array", "filter_has_var"]}

tests/TestMslsCustomColumnTaxonomy.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace lloc\MslsTests;
44

55
use lloc\Msls\MslsBlogCollection;
6-
use lloc\Msls\MslsCustomColumn;
76
use lloc\Msls\MslsCustomColumnTaxonomy;
87
use lloc\Msls\MslsOptions;
98

tests/TestMslsCustomFilter.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,40 @@
55
use lloc\Msls\MslsBlogCollection;
66
use lloc\Msls\MslsCustomFilter;
77
use lloc\Msls\MslsOptions;
8-
use Mockery\Mock;
8+
use Brain\Monkey\Functions;
99

1010
class TestMslsCustomFilter extends MslsUnitTestCase {
1111

12-
public function test_execute_filter(): void {
13-
$options = \Mockery::mock( MslsOptions::class );
12+
protected function setUp(): void
13+
{
14+
parent::setUp(); // TODO: Change the autogenerated stub
1415

15-
$collection = \Mockery::mock( MslsBlogCollection::class );
16-
$collection->shouldReceive( 'get' )->once()->andReturn( [] );
16+
$options = \Mockery::mock( MslsOptions::class );
1717

18-
$query = \Mockery::mock( 'WP_Query' );
18+
$collection = \Mockery::mock( MslsBlogCollection::class );
19+
$collection->shouldReceive( 'get' )->once()->andReturn( [] );
1920

20-
$obj = new MslsCustomFilter( $options, $collection );
21+
$this->test = new MslsCustomFilter( $options, $collection );
2122

22-
$this->assertFalse( $obj->execute_filter( $query ) );
23+
}
24+
25+
public function test_execute_filter(): void {
26+
$query = \Mockery::mock( 'WP_Query' );
27+
28+
$this->assertFalse( $this->test->execute_filter( $query ) );
2329
}
2430

31+
public function test_execute_filter_with_filter_input(): void {
32+
Functions\expect('filter_has_var')->once()->with( INPUT_GET, 'msls_filter' )->andReturn( true );
33+
34+
$query = \Mockery::mock( 'WP_Query' );
35+
36+
$this->assertFalse( $this->test->execute_filter( $query ) );
37+
}
38+
39+
public function test_add_filter(): void {
40+
$this->expectOutputString('' );
41+
42+
$this->test->add_filter();
43+
}
2544
}

0 commit comments

Comments
 (0)