1
0
Fork 0
mirror of https://github.com/archtechx/virtualcolumn.git synced 2026-02-04 18:24:03 +00:00

Add regression test for timestamps being included in the data column

This commit is contained in:
lukinovec 2025-07-22 09:43:26 +02:00
parent 0f4d04ee4f
commit ac55a5b5ec
2 changed files with 52 additions and 0 deletions

View file

@ -157,6 +157,28 @@ class VirtualColumnTest extends TestCase
// Reset static property
MyModel::$customEncryptedCastables = [];
}
public function testUpdatingModelDoesNotStoreTimestampsInTheVirtualColumn() {
/** @var TimestampModel $model */
$model = TimestampModel::create();
$dbRecordDataColumn = fn () => DB::selectOne('select * from timestamp_models where id = ?', [$model->id])->data;
$this->assertStringNotContainsString('created_at', $dbRecordDataColumn());
$this->assertStringNotContainsString('updated_at', $dbRecordDataColumn());
$model->update(['data' => ['virtual' => 'bar']]);
$this->assertStringNotContainsString('created_at', $dbRecordDataColumn());
$this->assertStringNotContainsString('updated_at', $dbRecordDataColumn());
}
}
class TimestampModel extends Model
{
use VirtualColumn;
public $timestamps = true;
protected $guarded = [];
}
class ParentModel extends Model