Skip to content

Commit f3dd2f0

Browse files
committed
Update test sprout model with exceptions on missing update.
1 parent ff6190d commit f3dd2f0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/Models/SproutModel.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace kbtests\Models;
44

5-
use karmabunny\pdb\Pdb;
5+
use karmabunny\pdb\Exceptions\RowMissingException;
66

77
/**
88
* Base models from Sprout.
@@ -49,7 +49,11 @@ protected function _internalSave(array &$data)
4949
$table = static::getTableName();
5050

5151
if ($this->id > 0) {
52-
$pdb->update($table, $data, [ 'id' => $this->id ]);
52+
$count = $pdb->update($table, $data, [ 'id' => $this->id ]);
53+
54+
if (!$count) {
55+
throw new RowMissingException("Failed to update record for '{$table}'");
56+
}
5357
}
5458
else {
5559
$data['id'] = $pdb->insert($table, $data);
@@ -58,11 +62,15 @@ protected function _internalSave(array &$data)
5862
if (property_exists($this, 'uid')) {
5963
$data['uid'] = $pdb->generateUid($table, $data['id']);
6064

61-
$pdb->update(
65+
$count = $pdb->update(
6266
$table,
6367
[ 'uid' => $data['uid'] ],
6468
[ 'id' => $data['id'] ]
6569
);
70+
71+
if (!$count) {
72+
throw new RowMissingException("Failed to update record for '{$table}'");
73+
}
6674
}
6775
}
6876
}

0 commit comments

Comments
 (0)