The pattern is the same: if something needs access to a value (db, data store, etc.) it should be taken as an argument, not accessed as a global variable.  This is not "test"-related.  It's making the external requirements of the code explicit.  In doing so it also makes the code easier to test and easier to use in multiple contexts.