I'm in the process of testing a factory class. One of the methods must load the data in an array for an object that another method will instantiate.

That method contains the SQL query that holds a critical condition that must be tested. ( in this case only ask for the records that are "published". Ex.: WHERE published=1 ). That distinction in the SQL Query is the only detail that makes that method differ from another one, and I want to test the query execution behaviour.

Now, I can't really mock my PDO object and ask it to return a fixed result as I would not test the execution of the query by mySQL. That would make a useless test.

That leads me to think that I'll need to set up a static database with fixed test data inside it. Am I right on this or have I missed something?

Should I separate the test requiring the "test database" from the tests that are autonomous ?

Edit
Report