| 293 | * Assert that a table has a primary key. |
| 294 | * |
| 295 | * Checks for single-column primary keys. May not work for multi-column primary keys. |
| 296 | * |
| 297 | * @param string $column The column for the primary key. |
| 298 | * @param string $table The database table name. |
| 299 | */ |
| 300 | protected function assertTableHasPrimaryKey( $column , $table ) { |
| 301 | global $wpdb; |
| 302 | $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};"); |
| 303 | $this->assertCount( 1, wp_list_filter( $tableindices, array( 'Key_name' => 'PRIMARY' , 'Column_name' => $column ) , 'AND' ) ); |
| 304 | } |
| 305 | |
| 306 | /** |