This information is from the code coverage report (see http://coverage.cwgordon.com/coverage).

We need to test:

1) _db_create_field_sql() with precision and scale.
2) db_rename_table().
3) db_add_field().
4) db_drop_field().
5) db_field_set_default().
6) db_field_set_no_default().
7) db_add_primary_key().
8) db_drop_primary_key().
9) db_add_unique_key().
10) db_drop_unique_key().
11) db_add_index().
12) db_drop_index().
13) db_change_field().
14) Unsupported database versions.
15) 'dev_query' database option.
16) db_query_temporary()
17) db_lock_table()
18) db_unlock_tables()
19) db_column_exists()
20) db_distinct_field()

Comments

catch’s picture

Status: Active » Postponed

Since http://drupal.org/node/225450 comes with tests, we should postpone this pending the outcome of that issue (although let's hope there's only one possible outcome). Might as well test code that's not disappearing imminently.

Crell’s picture

Title: Tests needed: database.*.inc » Tests needed: Database layer
Assigned: Unassigned » Crell
Status: Postponed » Needs review
StatusFileSize
new53.55 KB

I'm stealing this issue to submit the tests that were written for the new DB layer. This covers all tests written to date. We certainly can add more, but let's start with these. :-)

catch’s picture

I had a very, very quick read through and nothing bad jumped out, and ran all tests (they pass). Are these what used to be with dbtest.module? In that case, they've probably been reviewed a few times before anyway, but leaving this open in case someone's got time to take a closer look.

floretan’s picture

The patch looks good functionally, but some clean-up is required:
- Indentation is off in a few places.
- Some comments contain development messages (like "// Barry, what's going on here? :-) --LG")
- Empty setUp() declarations are not necessary.

Anonymous’s picture

Status: Needs review » Needs work

@flobruit: You should have changed the Status to CNW.

dmitrig01’s picture

Your code style is inconsitant

+      $before_age = db_query("SELECT age FROM {test} WHERE name='Ringo'")->fetchField();
+      $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField();
+      $person = db_query("SELECT * FROM {test} WHERE name=:name", array(':name' => 'Ringo'))->fetch();

some places it's field = value others field=value

floretan’s picture

Status: Needs work » Needs review
StatusFileSize
new53.46 KB

A first round of fixes:
- Add t() to assertion messages, wrapped with single quotes where appropriate and sentences ending with a period.
- Remove empty setUp() calls.
- Fixed indentation in a few places.

All tests still pass.

Question:
Generally, the call to parent::tearDown() should be at the end of tearDown(), but doing so causes the test to throw uncaught exceptions (the tests still pass).

floretan’s picture

StatusFileSize
new52.94 KB

The problem with the tearDown() function was duplicate code between DatabaseTestCase::tearDown() and DrupalWebTestCase::tearDown(). Deleting the test tables (test, test_people, test_one_blob, test_two_blob and test_task) in DatabaseTestCase::tearDown() is not necessary as those tables are deleted automatically by the parent method.

Only difference with previous patch is the absence of tearDown() method.

floretan’s picture

StatusFileSize
new52.94 KB

Fixed the inconsistency pointed out in #6 (chose field = value).

Crell’s picture

StatusFileSize
new53.61 KB

Thanks, flobruit!

The attached patch is the same as #9 except with a few whitespace changes to make the coding style of chained methods a little tighter.

zoo33’s picture

All tests passed!

zoo33’s picture

PHP shows a notice though:

[31-Aug-2008 12:59:00] PHP Notice:  Undefined property:  stdClass::$age in /xxxx/modules/simpletest/tests/database_test.test on line 1308

Apache/2.0.59
PHP Version 5.2.5
MySQL 5.0.41

catch’s picture

Crell’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new59.16 KB

Now with additional comments!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed! :D

webchick’s picture

Status: Fixed » Needs work

D'oh. :P Committed too soon.

Undefined property: stdClass::$age Notice database_test.test 1485

mustafau’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.78 KB

Tests do not finish on PostgreSQL. Edit: PostgreSQL 8.1

"testInsertFieldOnlyDefinition" gives "Uncaught exception" error.

Adding a try-catch statement allows tests to finish.

Crell’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new880 bytes

Oopsies. Try this.

webchick’s picture

Status: Needs work » Needs review

Ok, I committed Crell's small notice fix. mustafu's could use review.

cwgordon7’s picture

Status: Needs review » Needs work

Don't use $this->assertTrue(FALSE). Use $this->fail().

Crell’s picture

Status: Needs work » Fixed

The main bulk of this patch is already in, so can we file a separate issue for the cleanup? I much prefer that to fixing and re-opening an issue over and over again. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.