Lets say you have a website, that uses a function to retrieve data from the database and returns the result to be displayed/parsed/etc...
Since the data that is retrieve
Most tests focus on the logic paths that are involved in things like obtaining data. Not on the validity of the data itself. Validity of data is only meaningful if your application is somehow calculating or aggregating it or whatever, in which case you should be able to control the inputs and verify that the results are correct.
That said, sometimes you do want to hit the same database your app is using to verify returns. For example, if you're testing a function that returns a filtered dataset, your unit test could perform the same query and then do a row-by-row comparison of, say, each records primary key, and verify that your function returned the same set of data you were expecting.
I don't know if this is your specific question, but there's nothing wrong with hitting the database to perform asserts in unit tests, on the contrary. At least I do it all the time and no one has tried to have me arrested :)