diff options
author | Christian Schneider | 2020-06-24 14:45:27 +0200 |
---|---|---|
committer | Christian Schneider | 2020-06-24 14:45:27 +0200 |
commit | 53cc7ab05afb41a80b710fa1f4454a8e4cb372ab (patch) | |
tree | f2bbb606c02a3a6f248e40d58009cab5dd1c98a2 /test | |
parent | 5c26a69b002b7f66b95ae4a0da0d7ed0b9490fb1 (diff) | |
download | itools-53cc7ab05afb41a80b710fa1f4454a8e4cb372ab.tar.gz itools-53cc7ab05afb41a80b710fa1f4454a8e4cb372ab.tar.bz2 itools-53cc7ab05afb41a80b710fa1f4454a8e4cb372ab.zip |
Add static and pure replacements _read_postprocess/_write_preprocess for deprecated _read_post_process/_write_pre_process
Diffstat (limited to 'test')
-rwxr-xr-x | test/it_dbi.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/it_dbi.t b/test/it_dbi.t index 750841a..b09cdbb 100755 --- a/test/it_dbi.t +++ b/test/it_dbi.t @@ -422,3 +422,35 @@ is(allrecs(), '[{"ID":4,"foo":"C"}]', 'data after delete_untouched after replace $record->upsert(['ID' => 4, 'foo' => "C"]); is($record->delete_untouched(), [], 'delete_untouched after upsert without changes'); is(allrecs(), '[{"ID":4,"foo":"C"}]', 'data after delete_untouched after upsert without changes'); + +# +# Test _read_postprocess and _write_preprocess +# +class my_dbi_test extends it_dbi_test +{ + +static function _read_postprocess($data) +{ + $data['x']--; + return $data; +} + +static function _write_preprocess($data) +{ + $data['x']++; + return $data; +} + +} + +$record = new my_dbi_test; +$record->delete(['WHERE 1' ]); +$record->upsert(['ID' => 1, 'x' => 42, 'foo' => "a"]); +$record->read(1); +is($record->x, 42, 'value of x after reading with _read_postprocess'); +is($record->_data, ["ID" => 1, "x" => 42, 'foo' => "a"], 'data after reading with _read_postprocess'); + +$record2 = new it_dbi_test; +$record2->read(1); +is($record2->x, 43, 'raw value of x after writing with _write_preprocess'); +is($record2->_data, ["ID" => 1, "x" => 43, 'foo' => "a"], 'raw data after writing with _write_preprocess'); |