wordpress-develop/tests/phpunit/tests/rewrite/permastructs.php
Gary Pendergast 8f95800d52 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-30 23:09:33 +00:00

43 lines
1015 B
PHP

<?php
/**
* @group rewrite
*/
class Tests_Rewrite_Permastructs extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
$this->set_permalink_structure( '/%postname%/' );
}
public function test_add_permastruct() {
global $wp_rewrite;
add_permastruct( 'foo', 'bar/%foo%' );
$this->assertEqualSetsWithIndex(
array(
'with_front' => true,
'ep_mask' => EP_NONE,
'paged' => true,
'feed' => true,
'walk_dirs' => true,
'endpoints' => true,
'forcomments' => false,
'struct' => '/bar/%foo%',
), $wp_rewrite->extra_permastructs['foo']
);
}
public function test_remove_permastruct() {
global $wp_rewrite;
add_permastruct( 'foo', 'bar/%foo%' );
$this->assertInternalType( 'array', $wp_rewrite->extra_permastructs['foo'] );
$this->assertSame( '/bar/%foo%', $wp_rewrite->extra_permastructs['foo']['struct'] );
remove_permastruct( 'foo' );
$this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
}
}