function test_insert3()
 {
     global $wpdb;
     $P = new SP_Post();
     $post = array();
     $post['post_title'] = 'Test Meta';
     $post['a'] = 'Apple';
     $post['b'] = 'Banana';
     $post['c'] = 'Carrot';
     $this->post_id = $P->insert($post);
     $this->assertTrue($this->post_id);
     // Make sure each custom field corresponds to one row in wp_postmeta
     $sql = $wpdb->prepare("SELECT meta_key, count(*) as cnt FROM {$wpdb->postmeta} WHERE post_id=%s GROUP BY meta_key", $this->post_id);
     $results = $wpdb->get_results($sql, ARRAY_A);
     $this->assertTrue($results);
     foreach ($results as $r) {
         $this->assertTrue($r['cnt'] == 1);
     }
     // Nothing changed: make sure additional rows weren't created.
     $result = $P->update($post, $this->post_id);
     $this->assertTrue($result == $this->post_id);
     // Make sure each custom field corresponds to one row in wp_postmeta
     $sql = $wpdb->prepare("SELECT meta_key, count(*) as cnt FROM {$wpdb->postmeta} WHERE post_id=%s GROUP BY meta_key", $this->post_id);
     $results = $wpdb->get_results($sql, ARRAY_A);
     $this->assertTrue($results);
     foreach ($results as $r) {
         $this->assertTrue($r['cnt'] == 1);
     }
     // Try nuking a custom field
     unset($post['c']);
     // Nothing changed: make sure additional rows weren't created.
     $result = $P->update($post, $this->post_id, true);
     $this->assertTrue($result == $this->post_id);
     $post = $P->get($this->post_id);
     $this->assertTrue(!isset($post['c']));
     // Make sure each custom field corresponds to one row in wp_postmeta
     $sql = $wpdb->prepare("SELECT meta_key, count(*) as cnt FROM {$wpdb->postmeta} WHERE post_id=%s GROUP BY meta_key", $this->post_id);
     $results = $wpdb->get_results($sql, ARRAY_A);
     $this->assertTrue($results);
     foreach ($results as $r) {
         $this->assertTrue($r['cnt'] == 1);
     }
     // Cleanup: Make sure it's gone
     $P->delete($this->post_id);
     $post = $P->get($this->post_id);
     $this->assertTrue(empty($post));
 }