? sites/default/modules ? sites/default/settings.php Index: modules/simpletest/tests/database_test.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.test,v retrieving revision 1.9 diff -u -p -r1.9 database_test.test --- modules/simpletest/tests/database_test.test 28 Sep 2008 21:52:08 -0000 1.9 +++ modules/simpletest/tests/database_test.test 14 Oct 2008 13:16:00 -0000 @@ -486,6 +486,36 @@ class DatabaseInsertLOBTestCase extends } /** + * Test that we can insert a null blob field successfully. + * + * NOTE: Require PHP 5.2 newer than snapshot php5.2-200810130030.tar.gz. + * @link http://bugs.php.net/bug.php?id=46249 + */ + function testInsertNullBlob() { + $data = NULL; + $this->assertTrue($data === NULL, t('Test data is a null string.')); + $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); + $res = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id)); + $r = db_fetch_array($res); + $this->assertTrue($r['blob1'] === $data, t('Can insert a null blob: id @id, type @type, @data.', array('@id' => $id, '@type' => gettype($r['blob1']), '@data' => serialize($r)))); + } + + /** + * Test that we can insert an empty blob field successfully. + * + * NOTE: Require PHP 5.2 newer than snapshot php5.2-200810130030.tar.gz. + * @link http://bugs.php.net/bug.php?id=46249 + */ + function testInsertEmptyBlob() { + $data = ''; + $this->assertTrue($data === '', t('Test data is an empty string.')); + $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); + $res = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id)); + $r = db_fetch_array($res); + $this->assertTrue($r['blob1'] === $data, t('Can insert an empty blob: id @id, type @type, @data.', array('@id' => $id, '@type' => gettype($r['blob1']), '@data' => serialize($r)))); + } + + /** * Test that we can insert multiple blob fields in the same query. */ function testInsertMultipleBlob() { @@ -743,7 +773,7 @@ class DatabaseUpdateLOBTestCase extends function getInfo() { return array( - 'name' => t('Update tests, LOB'), + 'name' => t('Update tests, LOB fields'), 'description' => t('Test the Update query builder with LOB fields.'), 'group' => t('Database'), ); @@ -766,6 +796,46 @@ class DatabaseUpdateLOBTestCase extends } /** + * Confirm that we can update a null blob column. + * + * NOTE: Require PHP 5.2 newer than snapshot php5.2-200810130030.tar.gz. + * @link http://bugs.php.net/bug.php?id=46249 + */ + function testUpdateNullBlob() { + $data = "This is\000a test."; + $this->assertTrue(strlen($data) === 15, t('Test data contains a NULL.')); + $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); + + $data = NULL; + $this->assertTrue($data === NULL, t('Test data is a null string.')); + db_update('test_one_blob')->condition('id', $id)->fields(array('blob1' => $data))->execute(); + + $res = db_query('SELECT * FROM {test_one_blob} WHERE id = %d', $id); + $r = db_fetch_array($res); + $this->assertTrue($r['blob1'] === $data, t('Can update a null blob: id @id, type @type, @data.', array('@id' => $id, '@type' => gettype($r['blob1']), '@data' => serialize($r)))); + } + + /** + * Confirm that we can update an empty blob column. + * + * NOTE: Require PHP 5.2 newer than snapshot php5.2-200810130030.tar.gz. + * @link http://bugs.php.net/bug.php?id=46249 + */ + function testUpdateEmptyBlob() { + $data = "This is\000a test."; + $this->assertTrue(strlen($data) === 15, t('Test data contains a NULL.')); + $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); + + $data = ''; + $this->assertTrue($data === '', t('Test data is an empty string.')); + db_update('test_one_blob')->condition('id', $id)->fields(array('blob1' => $data))->execute(); + + $res = db_query('SELECT * FROM {test_one_blob} WHERE id = %d', $id); + $r = db_fetch_array($res); + $this->assertTrue($r['blob1'] === $data, t('Can update an empty blob: id @id, type @type, @data.', array('@id' => $id, '@type' => gettype($r['blob1']), '@data' => serialize($r)))); + } + + /** * Confirm that we can update two blob columns in the same table. */ function testUpdateMultipleBlob() {