mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +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:
@@ -22,14 +22,9 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
|
||||
update_option( 'comments_per_page', 5 );
|
||||
update_option( 'posts_per_page', 5 );
|
||||
|
||||
global $wp_rewrite;
|
||||
|
||||
$wp_rewrite->init();
|
||||
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
|
||||
create_initial_taxonomies();
|
||||
|
||||
$wp_rewrite->flush_rules();
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
|
||||
@@ -23,7 +23,6 @@ class Tests_Query_IsTerm extends WP_UnitTestCase {
|
||||
protected $tax;
|
||||
|
||||
function setUp() {
|
||||
global $wp_rewrite;
|
||||
parent::setUp();
|
||||
|
||||
set_current_screen( 'front' );
|
||||
@@ -31,13 +30,12 @@ class Tests_Query_IsTerm extends WP_UnitTestCase {
|
||||
$GLOBALS['wp_the_query'] = new WP_Query();
|
||||
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
|
||||
|
||||
$wp_rewrite->init();
|
||||
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
|
||||
create_initial_taxonomies();
|
||||
register_taxonomy( 'testtax', 'post', array( 'public' => true ) );
|
||||
|
||||
$wp_rewrite->flush_rules();
|
||||
flush_rewrite_rules();
|
||||
|
||||
$this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
|
||||
$this->cat_id = $this->factory->category->create( array( 'slug' => 'cat-slug' ) );
|
||||
|
||||
@@ -8,15 +8,10 @@ require_once dirname( __FILE__ ) . '/conditionals.php';
|
||||
*/
|
||||
class Tests_Query_VerbosePageRules extends Tests_Query_Conditionals {
|
||||
function setUp() {
|
||||
global $wp_rewrite;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$wp_rewrite->init();
|
||||
$wp_rewrite->set_permalink_structure( '/%category%/%year%/%postname%/' );
|
||||
|
||||
create_initial_taxonomies();
|
||||
|
||||
$wp_rewrite->flush_rules();
|
||||
$this->set_permalink_structure( '/%category%/%year%/%postname%/' );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user