Ejemplo n.º 1
0
 /**
  * Test that the wp_ID column gets added to groups via the 1.1.0 updater
  *
  * @since 1.1.0
  *
  * @group db
  *
  * @covers \ingot\testing\db\add_wp_id_column()
  * @covers \ingot\testing\db\run()
  */
 public function test1dot1Update()
 {
     global $wpdb;
     $table_name = \ingot\testing\crud\group::get_table_name();
     //test method in isolation
     $wpdb->query(sprintf('ALTER TABLE %s DROP COLUMN wp_ID', $table_name));
     $updater = new \ingot\testing\db\upgrade('1.1.0');
     $updater->add_wp_id_column();
     $data = ingot_test_data_price::edd_tests(10);
     $this->assertTrue(is_array($data));
     $this->assertTrue(is_numeric($data['group_ID']));
     $product_ID = $data['product_ID'];
     $results = $wpdb->query(sprintf('SELECT * FROM `%s` WHERE `wp_ID` = %d', $table_name, $product_ID));
     $this->assertTrue(!empty($results));
     //test using run method
     $wpdb->query(sprintf('ALTER TABLE %s DROP COLUMN wp_ID', $table_name));
     $updater->run();
     $data = ingot_test_data_price::edd_tests(10);
     $this->assertTrue(is_array($data));
     $this->assertTrue(is_numeric($data['group_ID']));
     $product_ID = $data['product_ID'];
     $results = $wpdb->query(sprintf('SELECT * FROM `%s` WHERE `wp_ID` = %d', $table_name, $product_ID));
     $this->assertTrue(!empty($results));
     //test that running it anyway doesn't break stuff
     $results = $wpdb->query(sprintf('SELECT * FROM `%s` WHERE `wp_ID` = %d', $table_name, $product_ID));
     $this->assertTrue(!empty($results));
 }
Ejemplo n.º 2
0
 /**
  * Maybe run DB updater
  *
  * @access protected
  *
  * @since 1.0.1
  */
 protected static function maybe_upgrade()
 {
     if (INGOT_VER != get_option('ingot_version', 0)) {
         $updater = new \ingot\testing\db\upgrade(INGOT_VER);
         $updater->run();
         update_option('ingot_version', INGOT_VER, false);
     }
 }