示例#1
0
文件: bootstrap.php 项目: E-2/Revisr
<?php

$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin()
{
    require dirname(__FILE__) . '/../revisr.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
require $_tests_dir . '/includes/bootstrap.php';
//define( 'REVISR_GIT_DIR', '/tmp/wordpress' );
// Activate & install the plugin
Revisr::install();
示例#2
0
 /**
  * Tests the database installation.
  */
 function test_install()
 {
     Revisr::install();
     global $wpdb;
     $table_name = $wpdb->prefix . 'revisr';
     $table_check = $wpdb->get_var("SHOW TABLES LIKE '{$table_name}'");
     $this->assertEquals($table_name, $table_check);
 }
示例#3
0
 /**
  * Updates user settings to be compatible with 1.8.
  * @access public
  */
 public function do_upgrade()
 {
     global $wpdb;
     // For users upgrading from 1.7 and older.
     if (get_option('revisr_db_version') === '1.0') {
         // Check for the "auto_push" option and save it to the config.
         if (isset(revisr()->options['auto_push'])) {
             revisr()->git->set_config('revisr', 'auto-push', 'true');
         }
         // Check for the "auto_pull" option and save it to the config.
         if (isset(revisr()->options['auto_pull'])) {
             revisr()->git->set_config('revisr', 'auto-pull', 'true');
         }
         // Check for the "reset_db" option and save it to the config.
         if (isset(revisr()->options['reset_db'])) {
             revisr()->git->set_config('revisr', 'import-checkouts', 'true');
         }
         // Check for the "mysql_path" option and save it to the config.
         if (isset(revisr()->options['mysql_path'])) {
             revisr()->git->set_config('revisr', 'mysql-path', revisr()->options['mysql_path']);
         }
         // Configure the database tracking to use all tables, as this was how it behaved in 1.7.
         revisr()->git->set_config('revisr', 'db_tracking', 'all_tables');
     }
     // Upgrades from the "revisr_commits" custom post type to pure Git.
     $table = Revisr::get_table_name();
     $commits = $wpdb->get_results("SELECT * FROM {$table} WHERE event = 'commit'", ARRAY_A);
     if (is_array($commits) && !empty($commits)) {
         foreach ($commits as $commit) {
             // Get the commit short hash from the message.
             $msg_array = explode('#', $commit['message']);
             $commit_id = substr($msg_array[1], 0, 7);
             // Prepare the new message.
             $new_msg = sprintf(__('Committed <a href="%s">#%s</a> to the local repository.', 'revisr'), get_admin_url() . 'admin.php?page=revisr_view_commit&commit=' . $commit_id, $commit_id);
             // Update the existing message.
             $query = $wpdb->prepare("UPDATE {$table} SET message = %s WHERE id = '%d'", $new_msg, $commit['id']);
             $wpdb->query($query);
         }
     }
     // Update the database schema using dbDelta.
     Revisr::install();
 }