robwilkerson/CakePHP-Audit-Log-Plugin — pull request #15 by cdvrooman (2012-12-05 16:31:25+00:00)
Title: Auditable test cases with the Translate behavior

Auditable is working with all Translate behavior core tests that involve saving and/or updating. Core fixtures were extended to actAs AuditLog.Auditable and the corresponding modified fixtures were added.

The only 'surprise' was in the testMultipleCreate test case where Auditable was failing to save the translated item to the Audit table after saving its translations. The culprit was this statement:
```php
$Model->locale = 'deu';
```
which came into play when Auditable was executing the _getModelData() method and was trying to find an entry where the locale was 'deu' but no 'deu' related data had been previously saved. The workaround was to use a locale that had actually been specified, i.e. 'eng' or 'spa'.

One workaround to avoid the error and be able to save to Audit (although with only the model name and id in the json_object field would be to add the following:
```php
if ( !isset( $data[$Model->alias] ) ) {
return array();
}
```
before the
```php
$audit_data = array(
$Model->alias => $data[$Model->alias]
);
```
statement in the _getModelData() method.

Please note that no actual test cases where made to validate the existence of Audit and AuditDelta data. I used the query log to verify that data was going where it was supposed to.

Another discovery was when using the Translate behavior and Auditable, Auditable must be specified after Translate in the actsAs array.