Ticket #29020: 29020.4.diff
File 29020.4.diff, 1.3 KB (added by , 10 years ago) |
---|
-
tests/phpunit/tests/dbdelta.php
230 230 $this->assertTableHasNotColumn( 'extra_col', $wpdb->prefix . 'dbdelta_test' ); 231 231 } 232 232 233 /** 234 * Test inserting into the database 235 */ 236 public function test_insert_into_table(){ 237 global $wpdb; 238 239 $insert = dbDelta( 240 "INSERT INTO {$wpdb->prefix}dbdelta_test (column_1) VALUES ('wcphilly2015')" 241 ); 242 243 $this->assertEquals( 244 array( ) 245 , $insert 246 ); 247 248 $this->assertTableRowHasValue( 'column_1', 'wcphilly2015', $wpdb->prefix . 'dbdelta_test' ); 249 250 } 251 233 252 // 234 253 // Assertions. 235 254 // 236 255 237 256 /** 257 * Assert that a table has a row with a value in a field. 258 * 259 * @param string $column The field name. 260 * @param string $value The field value. 261 * @param string $table The database table name. 262 */ 263 protected function assertTableRowHasValue( $column, $value, $table ) { 264 265 global $wpdb; 266 267 $table_row = $wpdb->get_row( "select $column from {$table} where $column = '$value'" ); 268 269 $expected = (object) array( 270 $column => $value 271 ); 272 273 $this->assertEquals( $expected, $table_row ); 274 } 275 276 /** 238 277 * Assert that a table has a column. 239 278 * 240 279 * @param string $column The field name.