GFMFI_Tests_Bootstrap

Gravity Forms: Multiple Form Instances - Unit Tests Bootstrap.

Defined (1)

The class is defined in the following location(s).

/tests/bootstrap.php  
  1. class GFMFI_Tests_Bootstrap { 
  2.  
  3. /**  
  4. * The bootstrap instance. 
  5. * @var GFMFI_Tests_Bootstrap 
  6. */ 
  7. protected static $instance = null; 
  8.  
  9. /**  
  10. * Directory where wordpress-tests-lib is installed 
  11. * @var string 
  12. */ 
  13. public $wp_tests_dir; 
  14.  
  15. /**  
  16. * Testing directory. 
  17. * @var string 
  18. */ 
  19. public $tests_dir; 
  20.  
  21. /**  
  22. * Plugin directory. 
  23. * @var string 
  24. */ 
  25. public $plugin_dir; 
  26.  
  27. /** 
  28. * Setup the unit testing environment 
  29. */ 
  30. private function __construct() { 
  31.  
  32. ini_set( 'display_errors', 'on' ); 
  33. error_reporting( E_ALL ); 
  34.  
  35. $this->tests_dir = dirname( __FILE__ ); 
  36. $this->plugin_dir = dirname( $this->tests_dir ); 
  37. $this->wp_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : $this->plugin_dir . '/tmp/wordpress-tests-lib'; 
  38.  
  39. // load test function so tests_add_filter() is available 
  40. require_once( $this->wp_tests_dir . '/includes/functions.php' ); 
  41.  
  42. // load plugin 
  43. tests_add_filter( 'muplugins_loaded', array( $this, 'load_plugin' ) ); 
  44.  
  45. // load the WP testing environment 
  46. require_once( $this->wp_tests_dir . '/includes/bootstrap.php' ); 
  47.  
  48. // make sure query vars are prepared 
  49. global $wp; 
  50. if ( !is_array( $wp->query_vars ) ) { 
  51. $wp->query_vars = array(); 
  52.  
  53. /** 
  54. * Load the plugin 
  55. */ 
  56. public function load_plugin() { 
  57. require_once( $this->plugin_dir . '/gravityforms-multiple-form-instances.php' ); 
  58.  
  59. /** 
  60. * Get the single tests boostrap instance 
  61. * @return GFMFI_Tests_Bootstrap 
  62. */ 
  63. public static function instance() { 
  64. if ( is_null( self::$instance ) ) { 
  65. self::$instance = new self(); 
  66.  
  67. return self::$instance; 
  68.