forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoFoundRows.php
More file actions
105 lines (87 loc) · 2.02 KB
/
noFoundRows.php
File metadata and controls
105 lines (87 loc) · 2.02 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
97
98
99
100
101
102
103
104
105
<?php
/**
* @group query
*/
class Tests_Query_NoFoundRows extends WP_UnitTestCase {
public function test_no_found_rows_default() {
$q = new WP_Query(
array(
'post_type' => 'post',
)
);
$this->assertContains( 'SQL_CALC_FOUND_ROWS', $q->request );
}
public function test_no_found_rows_false() {
$q = new WP_Query(
array(
'post_type' => 'post',
'no_found_rows' => false,
)
);
$this->assertContains( 'SQL_CALC_FOUND_ROWS', $q->request );
}
public function test_no_found_rows_0() {
$q = new WP_Query(
array(
'post_type' => 'post',
'no_found_rows' => 0,
)
);
$this->assertContains( 'SQL_CALC_FOUND_ROWS', $q->request );
}
public function test_no_found_rows_empty_string() {
$q = new WP_Query(
array(
'post_type' => 'post',
'no_found_rows' => '',
)
);
$this->assertContains( 'SQL_CALC_FOUND_ROWS', $q->request );
}
public function test_no_found_rows_true() {
$q = new WP_Query(
array(
'post_type' => 'post',
'no_found_rows' => true,
)
);
$this->assertNotContains( 'SQL_CALC_FOUND_ROWS', $q->request );
}
public function test_no_found_rows_non_bool_cast_to_true() {
$q = new WP_Query(
array(
'post_type' => 'post',
'no_found_rows' => 'foo',
)
);
$this->assertNotContains( 'SQL_CALC_FOUND_ROWS', $q->request );
}
/**
* @ticket 29552
*/
public function test_no_found_rows_default_with_nopaging_true() {
$p = $this->factory->post->create();
$q = new WP_Query(
array(
'post_type' => 'post',
'nopaging' => true,
)
);
$this->assertNotContains( 'SQL_CALC_FOUND_ROWS', $q->request );
$this->assertSame( 1, $q->found_posts );
}
/**
* @ticket 29552
*/
public function test_no_found_rows_default_with_postsperpage_minus1() {
$p = $this->factory->post->create();
$q = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => -1,
)
);
$this->assertNotContains( 'SQL_CALC_FOUND_ROWS', $q->request );
$this->assertSame( 1, $q->found_posts );
}
}