私は単体テストを書いていますが、非常に奇妙な動作に遭遇しました。
私はテスト フィクスチャを持っているので、データベースに 1 行が表示されることを期待しています (フィクスチャには 1 行しか表示されません)。次のように、findByAttributes を実行するコードをいくつか書きました。
$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();
テストの実行後にこの構成があり、サイコロがヒットすると、データベースに 2 つの行が表示されます。しかし、もしそうなら:
$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.
フィクスチャから 1 行しか表示されません。テスト DB で findByAttributes が行を作成するのはなぜですか?