@@ 145-168 (lines=24) @@ | ||
142 | * |
|
143 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
|
144 | */ |
|
145 | function test_load_available_items_query_returns_post_item_with_page_number() { |
|
146 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
147 | ||
148 | // Create page. |
|
149 | $post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) ); |
|
150 | ||
151 | // Create pages. |
|
152 | $this->factory->post->create_many( 10 ); |
|
153 | ||
154 | // Expected menu item array. |
|
155 | $expected = array( |
|
156 | 'id' => "post-{$post_id}", |
|
157 | 'title' => 'Post Title', |
|
158 | 'type' => 'post_type', |
|
159 | 'type_label' => 'Post', |
|
160 | 'object' => 'post', |
|
161 | 'object_id' => intval( $post_id ), |
|
162 | 'url' => get_permalink( intval( $post_id ) ), |
|
163 | ); |
|
164 | ||
165 | // Offset the query and get the second page of menu items. |
|
166 | $items = $menus->load_available_items_query( 'post_type', 'post', 1 ); |
|
167 | $this->assertContains( $expected, $items ); |
|
168 | } |
|
169 | ||
170 | /** |
|
171 | * Test the load_available_items_query method returns page item. |
|
@@ 175-194 (lines=20) @@ | ||
172 | * |
|
173 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
|
174 | */ |
|
175 | function test_load_available_items_query_returns_page_item() { |
|
176 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
177 | ||
178 | // Create page. |
|
179 | $page_id = $this->factory->post->create( array( 'post_title' => 'Page Title', 'post_type' => 'page' ) ); |
|
180 | ||
181 | // Expected menu item array. |
|
182 | $expected = array( |
|
183 | 'id' => "post-{$page_id}", |
|
184 | 'title' => 'Page Title', |
|
185 | 'type' => 'post_type', |
|
186 | 'type_label' => 'Page', |
|
187 | 'object' => 'page', |
|
188 | 'object_id' => intval( $page_id ), |
|
189 | 'url' => get_permalink( intval( $page_id ) ), |
|
190 | ); |
|
191 | ||
192 | $items = $menus->load_available_items_query( 'post_type', 'page', 0 ); |
|
193 | $this->assertContains( $expected, $items ); |
|
194 | } |
|
195 | ||
196 | /** |
|
197 | * Test the load_available_items_query method returns post item. |
|
@@ 201-220 (lines=20) @@ | ||
198 | * |
|
199 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
|
200 | */ |
|
201 | function test_load_available_items_query_returns_post_item() { |
|
202 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
203 | ||
204 | // Create post. |
|
205 | $post_id = $this->factory->post->create( array( 'post_title' => 'Post Title' ) ); |
|
206 | ||
207 | // Expected menu item array. |
|
208 | $expected = array( |
|
209 | 'id' => "post-{$post_id}", |
|
210 | 'title' => 'Post Title', |
|
211 | 'type' => 'post_type', |
|
212 | 'type_label' => 'Post', |
|
213 | 'object' => 'post', |
|
214 | 'object_id' => intval( $post_id ), |
|
215 | 'url' => get_permalink( intval( $post_id ) ), |
|
216 | ); |
|
217 | ||
218 | $items = $menus->load_available_items_query( 'post_type', 'post', 0 ); |
|
219 | $this->assertContains( $expected, $items ); |
|
220 | } |
|
221 | ||
222 | /** |
|
223 | * Test the load_available_items_query method returns term item. |
|
@@ 227-246 (lines=20) @@ | ||
224 | * |
|
225 | * @see WP_Customize_Nav_Menus::load_available_items_query() |
|
226 | */ |
|
227 | function test_load_available_items_query_returns_term_item() { |
|
228 | $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); |
|
229 | ||
230 | // Create term. |
|
231 | $term_id = $this->factory->category->create( array( 'name' => 'Term Title' ) ); |
|
232 | ||
233 | // Expected menu item array. |
|
234 | $expected = array( |
|
235 | 'id' => "term-{$term_id}", |
|
236 | 'title' => 'Term Title', |
|
237 | 'type' => 'taxonomy', |
|
238 | 'type_label' => 'Category', |
|
239 | 'object' => 'category', |
|
240 | 'object_id' => intval( $term_id ), |
|
241 | 'url' => get_term_link( intval( $term_id ), 'category' ), |
|
242 | ); |
|
243 | ||
244 | $items = $menus->load_available_items_query( 'taxonomy', 'category', 0 ); |
|
245 | $this->assertContains( $expected, $items ); |
|
246 | } |
|
247 | ||
248 | /** |
|
249 | * Test the load_available_items_query method returns custom item. |