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.