Model Findbyattributes Seems To Create A Row In Cdbtestcase

I am writing a unit test, and I stumbled upon a very strange behavior.

I have a test fixture so I expect to see 1 row in the database (there is only 1 row listed in the fixture) I wrote some code to run a findByAttributes as follows:




$client_id = 6;

$unique = array (

    "client_id" => (String) $client_id,

    "id" => "2" //I have a fixture that uses id 1

);


$model = Agent::model()->findByAttributes($unique);

die();



When I have this configuration after my test runs and the die is hit, I see 2 rows in the database. However if I do:




$client_id = 6;

$unique = array (

    "client_id" => (String) $client_id,

    "id" => "2" //I have a fixture that uses id 1

);


die();

$model = Agent::model()->findByAttributes($unique);

//NOTE: I only moved the die() above the findByAttributes.



I see only the 1 row from my fixture. Why is findByAttributes creating a row in my test DB?

I noticed if I only supply the primary key no row is created. It is only when I supply a primary key and an additional value.

How can you test code after die(), considering php exit after die().

I put the die() in so the code will exit and I can examine the test database.

The Agent model is a Singleton model in my code, it obviously is going to create one if one does not exist. Sorry for the dumb question.