mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-30 18:24:31 +00:00
Tests: Permalink Structures Phase II: DRY up logic for setting permalink structures in test methods.
Renames `reset_permalinks()` to `set_permalink_structure()` (mimicking `$wp_rewrite->set_permalink_structure()`) and allows it to accept an optional permalink structure. In this way, we can double dip using it to both set and reset the permalink structure from anywhere. Removes alot of duplicated code from tests. See #33968. git-svn-id: https://develop.svn.wordpress.org/trunk@34810 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -50,7 +50,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
$this->reset_post_types();
|
||||
$this->reset_taxonomies();
|
||||
$this->reset_post_statuses();
|
||||
$this->reset_permalinks();
|
||||
$this->set_permalink_structure();
|
||||
}
|
||||
|
||||
$this->start_transaction();
|
||||
@@ -653,12 +653,14 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @global WP_Rewrite $wp_rewrite
|
||||
*
|
||||
* @param string $structure Optional. Permalink structure to set. Default empty.
|
||||
*/
|
||||
public function reset_permalinks() {
|
||||
public function set_permalink_structure( $structure = '' ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
$wp_rewrite->init();
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
$wp_rewrite->set_permalink_structure( $structure );
|
||||
$wp_rewrite->flush_rules();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user