I'm trying to learn how to write unit tests the 'proper' way and only test a specific component. (Using http://blog.stevensanderson.com/2009/08/24/writing-great-unit-tests-best-and-worst-practises/ for reference)
In one case, I've written a primative wrapper to query an old MS SQL 2000 database in PHP/PHPUnit. Without getting into specifics, it looks like this:
$mssql = MSSQL::connect($credentials); $mssql->insert($table, $assoc_array_of_data); $mssql->select($table, $columns, $where_clauses); $mssql->update($table, $assoc_array_of_data, $where_clauses); $mssql->delete($table, $where_clauses);
My question is, how would I structure a unit test to test each method in isolation, since they depend on each other? My current unit test basically does the following:
// Connect to the DB // Insert a test row // Select it to verify it made it in // Update the test row // Select it to verify the update worked // Delete the test row // Select it and verify it isn't there
Is this a proper approach to a unit test, or is there a better way?