[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/tests/phpunit/lib/ -> testcase.php (source)

   1  <?php
   2  
   3  require_once dirname( __FILE__ ) . '/factory.php';
   4  
   5  class GP_UnitTestCase extends WP_UnitTestCase {
   6  
   7      /**
   8       * @var string
   9       */
  10      public $url = 'http://example.org/';
  11  
  12      /**
  13       * @var GP_UnitTest_Factory
  14       */
  15      public $factory;
  16  
  17  	function setUp() {
  18          parent::setUp();
  19  
  20          $this->factory = new GP_UnitTest_Factory();
  21  
  22          global $wp_rewrite;
  23          if ( GP_TESTS_PERMALINK_STRUCTURE != $wp_rewrite->permalink_structure ) {
  24              $this->set_permalink_structure( GP_TESTS_PERMALINK_STRUCTURE );
  25          }
  26      }
  27  
  28      /**
  29       * Utility method that resets permalinks and flushes rewrites.
  30       *
  31       * Also updates the pre_option filter for `permalink_structure`.
  32       *
  33       * @global WP_Rewrite $wp_rewrite
  34       *
  35       * @param string $structure Optional. Permalink structure to set. Default empty.
  36       */
  37  	public function set_permalink_structure( $structure = '' ) {
  38          global $wp_tests_options;
  39  
  40          $wp_tests_options['permalink_structure'] = $structure;
  41  
  42          parent::set_permalink_structure( $structure );
  43      }
  44  
  45  	function clean_up_global_scope() {
  46          parent::clean_up_global_scope();
  47  
  48          $locales = &GP_Locales::instance();
  49          $locales->locales = array();
  50          $_GET = array();
  51          $_POST = array();
  52          /**
  53           * @todo re-initialize all thing objects
  54           */
  55          GP::$translation_set = new GP_Translation_Set;
  56          GP::$original = new GP_Original;
  57      }
  58  
  59  	function set_normal_user_as_current() {
  60          $user = $this->factory->user->create();
  61          wp_set_current_user( $user );
  62          return $user;
  63      }
  64  
  65  	function set_admin_user_as_current() {
  66          $admin = $this->factory->user->create_admin();
  67          wp_set_current_user( $admin );
  68          return $admin;
  69      }
  70  }


Generated: Thu Dec 26 01:01:15 2024 Cross-referenced by PHPXref 0.7.1