Fixtures Null Bug?

These fixtures are driving me nuts. (See other post about not loading properties). In this post, it’s about NULLs. Here’s a sample fixture:

'1220003-5-01P' => array(

    'line_item_id' => '1220003-5-01P',

    'fiscal_year' => 12,

    'quarter' => 2,

    'sequence_number' => '0003-01',

    'submission_date' => '08/02/2012',

    'description' => NULL,

    'notes' => NULL,

    'obligated_number' => NULL,

    'credit' => 200,

    'debit' => NULL,

    'balance' => 300,

    'fms_balance' => NULL,

    'charged' => false,

    'transaction_type' => 256,

    'obligated_date' => NULL,

    'obligated_amount' => NULL,

    'unobligated_balance' => NULL,

    'control_point_id' => 2,

    'project_id' => 3,

    'balance_sheet_id' => 5


Most of these NULL properties get to the unit test as null, not NULL. But one, fms_balance, shows up as "NULL", with the quotes. In other words, as a string? Why is it treated differently than all the others?

But it gets worse. When I run the test I get differences. The property ‘debit’, which in the fixture is set to NULL, comes up as a difference where expected is null, actual is NULL. The fixture is the expected result. So NULL in the fixture changed to null after the test, which for some reason is not equal to NULL, the result of the function being tested. The field in the database defaults to NULL, in case that’s the problem. Let me try to make this clearer. The fixture properties are what’s expected. In the case of ‘debit’, then, that should be NULL. The value from the database is the actual and it defaults to NULL, and comes through as NULL. But then the assertion says the expected was not NULL, but null and that’s different than NULL.

Sigh, I give up. I don’t seem to be able to make this clear.

Well, still don’t know if this is a bug but I found a way around it. Secret seems to be, don’t be so anal in the SQL and fixture files. Turns out there’s a big difference between adding DEFAULT (NULL) to a field and not adding it. Then lose all the fixture properties that are set to NULL and everything then seems to be null, lowercase and the unit test is happy.