Integration (and no unit) tests

I’ve been writing lots of integration tests lately, for a system that has zero unit tests. Does this make me a bad programmer? Probably. But it’s so easy! This is in Kohana, using ORM, and so the model basically is the database (which idea I rather like), and mocking it or splitting it out to be separate is just a pain. Far less code to write if one can test the whole interaction of the system at once.

I am being slightly tongue-in-cheek here, because I do realise that the maintenance burden of a system built with tight coupling between the various layers is likely to increase contiunually (to a point where someone at somepoint says “oh sod it, let’s rebuild from scratch on Drupal”). But for the multitude of systems that are basically just CRUD, the approach of writing tests that mimic the code seen in controllers is pretty simple and neat.

A DataLog for Kohana ORM models

A first draft of DataLog is up on Github now. It’s a Kohana module that works with ORM models for recording every change made to the data.

From the README:

This module is for keeping a log of changes made to ORM data. When added to an ORM model, it records who made what changes, when.

It stores actual values of the data (and usernames) rather than references to other parts of the database so that it can be as simple and robust as possible. This way it can be used with schema changes over time and still keep historical data.

There’s more to be figured out with this. The idea of tracking both the old and new values, for instance, may be inefficient. I’m working on Userguide pages, too — one of which will go over the idea of adding faux log messages, for things like file uploads, or modifications to related models that may not warrant a log in their own right (for example, ‘through’ tables where there is no model).

I wonder if it’s of any use to anyone other than me… hope so.