permastructs.php 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * @group rewrite
  4. */
  5. class Tests_Rewrite_Permastructs extends WP_UnitTestCase {
  6. public function setUp() {
  7. parent::setUp();
  8. $this->set_permalink_structure( '/%postname%/' );
  9. }
  10. public function test_add_permastruct() {
  11. global $wp_rewrite;
  12. add_permastruct( 'foo', 'bar/%foo%' );
  13. $this->assertSameSetsWithIndex(
  14. array(
  15. 'with_front' => true,
  16. 'ep_mask' => EP_NONE,
  17. 'paged' => true,
  18. 'feed' => true,
  19. 'walk_dirs' => true,
  20. 'endpoints' => true,
  21. 'forcomments' => false,
  22. 'struct' => '/bar/%foo%',
  23. ),
  24. $wp_rewrite->extra_permastructs['foo']
  25. );
  26. }
  27. public function test_remove_permastruct() {
  28. global $wp_rewrite;
  29. add_permastruct( 'foo', 'bar/%foo%' );
  30. $this->assertInternalType( 'array', $wp_rewrite->extra_permastructs['foo'] );
  31. $this->assertSame( '/bar/%foo%', $wp_rewrite->extra_permastructs['foo']['struct'] );
  32. remove_permastruct( 'foo' );
  33. $this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
  34. }
  35. }