public function test_register()
 {
     //make sure nobody else interfers with this test
     $this->_stop_pretending_addon_hook_time();
     remove_all_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders');
     $pretend_addon_name = 'More_Core';
     $args = array('dms_paths' => array(EE_TESTS_DIR . 'mocks/core/data_migration_scripts'));
     //try registering at wrong time
     try {
         EE_Register_Data_Migration_Scripts::register($pretend_addon_name, $args);
         $this->fail('We should have had a warning saying that we are setting up the ee addon at the wrong time');
     } catch (PHPUnit_Framework_Error_Notice $e) {
         $this->assertTrue(True);
     }
     //and check we didn't actually register the DMSs (because we attempted to do so at teh wrong time)
     $DMSs_available = EE_Data_Migration_Manager::reset()->get_all_data_migration_scripts_available();
     $this->assertArrayNotHasKey('EE_DMS_Core_1_0_0', $DMSs_available);
     //ok now pretend we're registering the DMS at the right time
     $this->_pretend_addon_hook_time();
     EE_Register_Data_Migration_Scripts::register($pretend_addon_name, $args);
     $DMSs_available = EE_Data_Migration_Manager::reset()->get_all_data_migration_scripts_available();
     $this->assertArrayHasKey('EE_DMS_Core_1_0_0', $DMSs_available);
     //now deregister it
     EE_Register_Data_Migration_Scripts::deregister($pretend_addon_name);
     $DMSs_available = EE_Data_Migration_Manager::reset()->get_all_data_migration_scripts_available();
     $this->assertArrayNotHasKey('EE_DMS_Core_1_0_0', $DMSs_available);
     $this->_stop_pretending_addon_hook_time();
 }
 /**
  * resets the instance and returns it
  * @return EE_System
  */
 public static function reset()
 {
     self::$_instance->_req_type = NULL;
     //make sure none of the old hooks are left hanging around
     remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
     //we need to reset the migration manager in order for it to detect DMSs properly
     EE_Data_Migration_Manager::reset();
     self::instance()->detect_activations_or_upgrades();
     self::instance()->perform_activations_upgrades_and_migrations();
     return self::instance();
 }
 public function tearDown()
 {
     if (isset($this->_addon_name) && isset(EE_Registry::instance()->addons->EE_New_Addon)) {
         $main_file_path_before_deregistration = EE_Registry::instance()->addons->EE_New_Addon->get_main_plugin_file_basename();
         EE_Register_Addon::deregister($this->_addon_name);
         try {
             EE_Registry::instance()->addons->EE_New_Addon;
             $this->fail('EE_New_Addon is still registered. Deregister failed');
         } catch (PHPUnit_Framework_Error_Notice $e) {
             $this->assertEquals(EE_UnitTestCase::error_code_undefined_property, $e->getCode());
         }
         //verify the deactvation hook was removed
         $this->assertFalse(has_action('deactivate_' . $main_file_path_before_deregistration));
         //verify the models were deregistered
         EE_System::instance()->load_core_configuration();
         $this->assertArrayDoesNotContain('EEM_New_Addon_Thing', EE_Registry::instance()->non_abstract_db_models);
         $this->assertArrayDoesNotContain('EEM_New_Addon_Thing', EE_Registry::instance()->models);
         EE_Registry::instance()->reset_model('Attendee');
         //verify that the model and class extensions have been removed
         $this->assertFalse($this->_class_has_been_extended());
         $this->assertFalse($this->_model_has_been_extended());
     }
     //verify DMSs deregistered
     $DMSs_available = EE_Data_Migration_Manager::reset()->get_all_data_migration_scripts_available();
     $this->assertArrayNotHasKey('EE_DMS_New_Addon_1_0_0', $DMSs_available);
     $this->_stop_pretending_addon_hook_time();
     $this->_stop_pretending_after_plugin_activation();
     remove_all_filters('AHEE__EE_System__load_espresso_addons');
     parent::tearDown();
 }
 /**
  * Resets the registry and everything in it (eventually, getting it to properly
  * reset absolutely everything will probably be tricky. right now it just resets
  * the config, data migration manager, and the models)
  * @param boolean $hard whether to reset data in the database too, or just refresh
  * the Registry to its state at the bginning of the request
  * @param boolean $reinstantiate whether to create new instances of EE_REgistry's singletons too,
  * or just reset without reinstantiating (handy to set to FALSE if you're not sure if you CAN
  * currently reinstantiate the singletons at the moment)
  * @return EE_Registry
  */
 public static function reset($hard = FALSE, $reinstantiate = TRUE)
 {
     $instance = self::instance();
     $instance->load_helper('Activation');
     EEH_Activation::reset();
     $instance->CFG = EE_Config::reset($hard, $reinstantiate);
     $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset();
     $instance->LIB = new stdClass();
     foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
         $instance->reset_model($model_name);
     }
     return $instance;
 }
 /**
  * restore the epsresso_db_update option
  */
 function tearDown()
 {
     update_option('espresso_db_update', $this->_original_espresso_db_update);
     EE_System::reset()->detect_req_type();
     EE_Data_Migration_Manager::reset();
     update_option(EE_Data_Migration_Manager::current_database_state, $this->_original_db_state);
     parent::tearDown();
 }
 private function _remove_mock_dms()
 {
     remove_filter('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array($this, 'add_mock_dms'));
     EE_Data_Migration_Manager::reset();
 }
 /**
  * the DMS manager maintains a bit of state in order to be more efficient, which we want to lose between tests
  */
 public function setUp()
 {
     EE_Data_Migration_Manager::reset();
     parent::setUp();
 }
 /**
  * @group 6910
  */
 public function test_enqueue_db_initialization_for()
 {
     EE_Data_Migration_Manager::reset()->enqueue_db_initialization_for('Core');
     EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Mock');
     $this->assertEquals(array('Core', 'Mock'), EE_Data_Migration_Manager::instance()->get_db_initialization_queue());
 }