Skip to content

Commit d99f6ee

Browse files
committed
Merge defaults with provided attribues
1 parent 785ce30 commit d99f6ee

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

tests/RandomPostOnRefreshTest.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@ public function test_build_query_args_minimal() {
8787
* Test build_query_args with author, ids, not, and search.
8888
*/
8989
public function test_build_query_args_with_filters() {
90-
$atts = array(
91-
'post_type' => 'post',
92-
'author' => '1,2',
93-
'ids' => '10,20',
94-
'not' => '5,6',
95-
'search' => 'test',
90+
$atts = array_merge(
91+
RandomPostOnRefresh::DEFAULT_ATTRIBUTES,
92+
array(
93+
'post_type' => 'post',
94+
'author' => '1,2',
95+
'ids' => '10,20',
96+
'not' => '5,6',
97+
'search' => 'test',
98+
)
9699
);
97100
$args = RandomPostOnRefresh::build_query_args( $atts );
98101
$this->assertEquals( array( 1, 2 ), $args['author__in'] );
@@ -105,10 +108,13 @@ public function test_build_query_args_with_filters() {
105108
* Test build_query_args with taxonomy and terms.
106109
*/
107110
public function test_build_query_args_with_taxonomy() {
108-
$atts = array(
109-
'post_type' => 'post',
110-
'taxonomy' => 'category',
111-
'terms' => '3,4',
111+
$atts = array_merge(
112+
RandomPostOnRefresh::DEFAULT_ATTRIBUTES,
113+
array(
114+
'post_type' => 'post',
115+
'taxonomy' => 'category',
116+
'terms' => '3,4',
117+
)
112118
);
113119
$args = RandomPostOnRefresh::build_query_args( $atts );
114120
$this->assertEquals( array( 3, 4 ), $args['category__in'] );
@@ -118,10 +124,13 @@ public function test_build_query_args_with_taxonomy() {
118124
* Test build_query_args with show=image and image_required=true.
119125
*/
120126
public function test_build_query_args_with_image_required() {
121-
$atts = array(
122-
'post_type' => 'post',
123-
'show' => 'title, image',
124-
'image_required' => 'true',
127+
$atts = array_merge(
128+
RandomPostOnRefresh::DEFAULT_ATTRIBUTES,
129+
array(
130+
'post_type' => 'post',
131+
'show' => 'title, image',
132+
'image_required' => 'true',
133+
)
125134
);
126135
$args = RandomPostOnRefresh::build_query_args( $atts );
127136
$this->assertArrayHasKey( 'meta_query', $args );

0 commit comments

Comments
 (0)