/**
  * Generate posts and build the sitemap
  */
 function setup()
 {
     _delete_all_posts();
     $this->test_base = new MSM_SiteMap_Test();
     // Add a post for each day in the last x years
     $dates = array();
     for ($i = 0; $i < $this->num_years_data; $i++) {
         // Add a post for x years ago
         $dates[] = (int) date('Y') - $i . '-' . date('m') . '-' . date('d') . ' 00:00:00';
     }
     $this->test_base->create_dummy_posts($dates);
     $this->assertCount($this->num_years_data, $this->test_base->posts);
     $this->test_base->build_sitemaps();
 }
Beispiel #2
0
 public function run()
 {
     /*
      * Globalize some WordPress variables, because PHPUnit loads this file inside a function
      * See: https://github.com/sebastianbergmann/phpunit/issues/325
      */
     global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer;
     if (!is_readable($this->get_config_file_path())) {
         die("ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n");
     }
     require_once $this->get_config_file_path();
     /**
      * @var string $table_prefix
      */
     define('WP_TESTS_TABLE_PREFIX', $table_prefix);
     // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only
     define('DISABLE_WP_CRON', true);
     define('WP_MEMORY_LIMIT', -1);
     define('WP_MAX_MEMORY_LIMIT', -1);
     $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
     $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN;
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
     if ("1" == getenv('WP_MULTISITE') || defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE) {
         $multisite = true;
     } else {
         $multisite = false;
     }
     $phpmailer = new MockPHPMailer();
     system(WP_PHP_BINARY . ' ' . escapeshellarg(dirname(__FILE__) . '/install.php') . ' ' . escapeshellarg($this->get_config_file_path()) . ' ' . $multisite);
     if ($multisite) {
         echo "Running as multisite..." . PHP_EOL;
         define('MULTISITE', true);
         define('SUBDOMAIN_INSTALL', false);
         $GLOBALS['base'] = '/';
     } else {
         echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL;
     }
     unset($multisite);
     require_once dirname(__FILE__) . '/functions.php';
     $GLOBALS['_wp_die_disabled'] = false;
     $this->setup_filters();
     // Load WordPress
     require_once $this->get_abspath() . '/wp-settings.php';
     // Delete any default posts & related data
     _delete_all_posts();
 }
Beispiel #3
0
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as  other settings.
if (isset($GLOBALS['wp_tests_options'])) {
    function wp_tests_options($value)
    {
        $key = substr(current_filter(), strlen('pre_option_'));
        return $GLOBALS['wp_tests_options'][$key];
    }
    foreach (array_keys($GLOBALS['wp_tests_options']) as $key) {
        tests_add_filter('pre_option_' . $key, 'wp_tests_options');
    }
}
// Load WordPress
require_once ABSPATH . '/wp-settings.php';
// Delete any default posts & related data
_delete_all_posts();
add_filter('user_has_cap', "ut_user_has_cap", 9, 3);
function ut_user_has_cap($all_caps, $cap, $args)
{
    $all_caps["gform_full_access"] = true;
    return $all_caps;
}
if (!class_exists('RGForms')) {
    require GRAVITYFORMS_BASE_PATH . 'gravityforms.php';
}
//require ABSPATH . 'wp-content/plugins/gravityflow/gravityflow.php';
require dirname(__FILE__) . '/testcase.php';
require dirname(__FILE__) . '/gravityforms-testcase.php';
require dirname(__FILE__) . '/testcase-xmlrpc.php';
require dirname(__FILE__) . '/testcase-ajax.php';
require dirname(__FILE__) . '/exceptions.php';
 public function bootstrap()
 {
     /*
      * Globalize some WordPress variables, because PHPUnit loads this file inside a function
      * See: https://github.com/sebastianbergmann/phpunit/issues/325
      *
      * These are not needed for WordPress 3.3+, only for older versions
      */
     global $table_prefix, $wp_embed, $wp_locale, $_wp_deprecated_widgets_callbacks, $wp_widget_factory;
     // These are still needed
     global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer;
     $this->startHeadlessRequest();
     // Install WordPress
     system(WP_PHP_BINARY . ' ' . escapeshellarg($this->bootstrapLocation) . ' install');
     // Load WordPress
     require_once ABSPATH . 'wp-settings.php';
     // Delete any default posts & related data
     _delete_all_posts();
     // Mock PHP Mailer
     require_once ABSPATH . 'wp-includes/class-phpmailer.php';
     $GLOBALS['phpmailer'] = new \MockPHPMailer();
     $GLOBALS['wppf'] = new \WPProfiler();
     function wppf_start($name)
     {
         $GLOBALS['wppf']->start($name);
     }
     function wppf_stop()
     {
         $GLOBALS['wppf']->stop();
     }
     function wppf_results()
     {
         return $GLOBALS['wppf']->results();
     }
     function wppf_print_summary()
     {
         $GLOBALS['wppf']->print_summary();
     }
 }
 function tearDown()
 {
     _delete_all_posts();
 }