Changeset 34222
- Timestamp:
- 03/09/2008 08:55:23 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
in-series/branches/maintenance/3.x/3.1/in-series-test/WordPressTestCase.php
r23344 r34222 2 2 /* 3 3 4 Copyright 2007 Travis Snoozy (ai2097@users.sourceforge.net)4 Copyright 2007,2008 Travis Snoozy (ai2097@users.sourceforge.net) 5 5 Released under the terms of the GNU GPL v2 6 6 … … 23 23 var $m_WPLoggedIn; 24 24 var $m_WPVersion; 25 var $m_WPWidgets; 25 26 26 27 function WordPressTestCase($label = false, $rootUrl = false, $username = false, $password = false, $version = null) { … … 42 43 $this->m_WPLoggedIn = false; 43 44 $this->m_WPVersion = $version; 45 $this->m_WPWidgets = array(); 44 46 } 45 47 … … 275 277 return $this->m_WPRootUrl."?p=$pid"; 276 278 } 279 280 function wpSetWidget($id, $set = true) { 281 $html = $this->get($this->m_WPRootUrl."wp-admin/widgets.php"); 282 $this->assertResponse(200); 283 $this->assertTrue($html); 284 285 $new_widgets = array(); 286 $widget_string = ''; 287 288 foreach($this->m_WPWidgets as $widget) { 289 if($widget == $id) { 290 $found = true; 291 if(!$set) { // Unset the widget by omitting it from the new list 292 continue; 293 } 294 else { // The widget is already set; bail (nothing to do) 295 return; 296 } 297 } 298 $new_widgets[] = $widget; 299 $widget_string .= $sep . "sidebar-1[]=" . $widget; 300 $sep = '&'; 301 } 302 303 if($set) { 304 $widget_string .= $sep . 'sidebar-1[]=' . $id; 305 $new_widgets[] = $id; 306 } 307 else if(!$found) { 308 return; // The widget is already unset; bail (nothing to do) 309 } 310 311 $this->m_WPWidgets = $new_widgets; 312 $this->assertTrue($this->setFieldById("sidebar-1order", $widget_string)); 313 $this->assertTrue($this->clickSubmit("Save Changes »")); 314 } 315 316 function wpClearWidgets() { 317 $html = $this->get($this->m_WPRootUrl."wp-admin/widgets.php"); 318 $this->assertResponse(200); 319 $this->assertTrue($html); 320 $this->assertTrue($this->setFieldById("sidebar-1order", "")); 321 $this->assertTrue($this->clickSubmit("Save Changes »")); 322 } 277 323 } 278 324
Note:
See TracChangeset
for help on using the changeset viewer.