forked from ryanwelcher/advanced-query-loop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExclude_Posts_Tests.php
More file actions
96 lines (85 loc) · 1.97 KB
/
Exclude_Posts_Tests.php
File metadata and controls
96 lines (85 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Tests for the Query_Params_Generator class.
*/
namespace AdvancedQueryLoop\UnitTests;
use AdvancedQueryLoop\Query_Params_Generator;
use PHPUnit\Framework\TestCase;
/**
* Test the generator class
*/
class Exclude_Posts_Tests extends TestCase {
/**
* Data provider for the empty array tests
*
* @return array
*/
public function data_returns_empty_array() {
return array(
array(
// Default values.
array(),
// Custom data.
array(),
),
array(
// Default values.
array(),
// Custom data.
array(
'exclude_posts' => array(),
),
),
);
}
/**
* All of these tests will return empty arrays
*
* @param array $default_data The params coming from the default block.
* @param array $custom_data The params coming from AQL.
*
* @dataProvider data_returns_empty_array
*/
public function test_exclude_posts_returns_empty( $default_data, $custom_data ) {
$qpg = new Query_Params_Generator( $default_data, $custom_data );
$qpg->process_all();
// Empty arrays return empty.
$this->assertEmpty( $qpg->get_query_args() );
}
/**
* Data provider for the non-empty array tests
*
* @return array
*/
public function data_basic_exclude_posts() {
return array(
array(
// Default values.
array(),
// Custom data.
array( 'exclude_posts' => array( 12, 13 ) ),
),
array(
// Default values.
array(),
// Custom data.
array(
'exclude_posts' => array( 12, 13 ),
),
),
);
}
/**
* Test that basics of setting an ID
*
* @param array $default_data The params coming from the default block.
* @param array $custom_data The params coming from AQL.
*
* @dataProvider data_basic_exclude_posts
*/
public function test_basic_exclude_posts( $default_data, $custom_data ) {
$qpg = new Query_Params_Generator( $default_data, $custom_data );
$qpg->process_all();
$this->assertEquals( array( 'post__not_in' => array( 12, 13 ) ), $qpg->get_query_args() );
}
}