コード例 #1
0
ファイル: tests-db.php プロジェクト: rene-hermenau/ingot
 /**
  * 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));
 }
コード例 #2
0
ファイル: price_query.php プロジェクト: rene-hermenau/ingot
 /**
  * Find all price tests by plugin type
  *
  * @since 1.1.0
  *
  * @param string $plugin Plugin -- must be allowed by ingot\testing\types::allowed_price_types()
  *
  * @return array
  */
 public static function find_by_plugin($plugin, $skip_no_variants = false)
 {
     if (in_array($plugin, types::allowed_price_types())) {
         $table_name = group::get_table_name();
         global $wpdb;
         $sql = sprintf('SELECT * FROM `%s` WHERE `sub_type` = "%s" AND `type` = "price"', $table_name, $plugin);
         if ($skip_no_variants) {
             $empty = serialize([]);
             $sql .= sprintf(' AND `variants` != "%s"', $empty);
         }
         return self::query($wpdb, $sql);
     }
 }
コード例 #3
0
ファイル: init.php プロジェクト: rene-hermenau/ingot
 /**
  * Get all destination tests
  *
  * @since 1.1.0
  *
  * @param bool $ids Optional. If true, the ID of found groups is returned. If false, full group configs are returned
  *
  * @return array|null|object
  */
 public static function get_destination_tests($ids = true)
 {
     global $wpdb;
     if ($ids) {
         $select = '`ID`';
     } else {
         $select = '*';
     }
     $tablename = group::get_table_name();
     $sql = sprintf("SELECT %s FROM `%s` WHERE `type` = 'click' AND `sub_type` = 'destination'", $select, $tablename);
     $results = $wpdb->get_results($sql, ARRAY_A);
     if (!empty($results)) {
         if ($ids) {
             $results = wp_list_pluck($results, 'ID');
         } else {
             $results = group::bulk_results($results);
         }
     }
     return $results;
 }
コード例 #4
0
ファイル: upgrade.php プロジェクト: rene-hermenau/ingot
 /**
  * Add wp_ID column to the groups table
  *
  * @since 1.1.0
  */
 public function add_wp_id_column()
 {
     global $wpdb;
     $table_name = group::get_table_name();
     $wpdb->query(sprintf("ALTER TABLE %s ADD COLUMN wp_ID VARCHAR(255) NOT NULL", $table_name));
 }
コード例 #5
0
ファイル: delta.php プロジェクト: rene-hermenau/ingot
 /**
  * Check if all tables exists
  *
  * @since 1.1.0
  * @since 0.3.0 in class ingot_boostrap
  *
  * @access protected
  *
  * @return bool
  */
 public static function check_if_tables_exist()
 {
     if (!self::table_exists(\ingot\testing\crud\tracking::get_table_name()) || !self::table_exists(\ingot\testing\crud\group::get_table_name()) || !self::table_exists(\ingot\testing\crud\session::get_table_name()) || !self::table_exists(\ingot\testing\crud\variant::get_table_name())) {
         return false;
     }
     return true;
 }
コード例 #6
0
ファイル: tests-group_crud.php プロジェクト: Ramoonus/ingot
 /**
  * Test that table name is right
  *
  * @since 0.0.7
  *
  * @group crud
  * @group group
  * @group group_crud
  *
  * @covers \ingot\testing\crud\tracking::get_table_name()
  */
 public function testTableName()
 {
     $tablename = \ingot\testing\crud\group::get_table_name();
     global $wpdb;
     $this->assertEquals($wpdb->prefix . 'ingot_group', $tablename);
 }
コード例 #7
0
ファイル: price.php プロジェクト: rene-hermenau/ingot
 /**
  * Check if a price test group already exists for a given product
  *
  * @since 1.1.0
  *
  * @param int $product_id Product ID
  *
  * @return bool|int False if none exist, ID of existing group if found.
  */
 public static function product_test_exists($product_id)
 {
     global $wpdb;
     $table_name = \ingot\testing\crud\group::get_table_name();
     $sql = sprintf('SELECT `ID` FROM `%s` WHERE `wp_ID` = %d AND `type` = "price"', $table_name, $product_id);
     $result = $wpdb->query($sql, ARRAY_A);
     if (empty($result)) {
         return false;
     } else {
         if (is_numeric($result)) {
             return $result;
         }
         if (is_array($result) && isset($result[0])) {
             $result[0];
         }
         return true;
     }
 }