Rewrite: Ensure `WP_Rewrite::flush_rules()` does not delete the 'rewrite_rules' option.

Instead, the option gets updated to an empty string.
Adds unit tests.

Props SergeyBiryukov, jesin, voldemortensen.
Fixes #29107.

git-svn-id: https://develop.svn.wordpress.org/trunk@36254 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-01-10 19:01:13 +00:00
parent 519051b305
commit 94992e25ae
1 changed files with 15 additions and 0 deletions

View File

@ -320,4 +320,19 @@ class Tests_Rewrite extends WP_UnitTestCase {
$this->set_permalink_structure();
}
/**
* @ticket 29107
*/
public function test_flush_rules_does_not_delete_option() {
$this->set_permalink_structure();
$rewrite_rules = get_option( 'rewrite_rules' );
$this->assertSame( '', $rewrite_rules );
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
$rewrite_rules = get_option( 'rewrite_rules' );
$this->assertInternalType( 'array', $rewrite_rules );
$this->assertNotEmpty( $rewrite_rules );
}
}