1
0
Fork 0
mirror of https://github.com/archtechx/virtualcolumn.git synced 2025-12-12 15:14:04 +00:00

Test that with encrypted casts, the encrypted values are saved in the DB (#21)

This commit is contained in:
lukinovec 2025-12-06 16:34:56 +01:00 committed by GitHub
parent 75718edcfe
commit 9da2d6fe8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -146,11 +146,14 @@ class VirtualColumnTest extends TestCase
'null_value' => null, // 'encrypted' 'null_value' => null, // 'encrypted'
]); ]);
$databaseRecord = json_decode(DB::select('SELECT data FROM my_models')[0]->data);
foreach($encryptedAttributes as $key => $expectedValue) { foreach($encryptedAttributes as $key => $expectedValue) {
$savedValue = $model->getAttributes()[$key]; // Encrypted $savedValue = $model->getAttributes()[$key]; // Encrypted
if ($savedValue !== null) { if ($savedValue !== null) {
$this->assertTrue($model->valueEncrypted($savedValue)); $this->assertTrue($model->valueEncrypted($savedValue));
$this->assertEquals($savedValue, $databaseRecord->$key); // Encrypted in DB
$this->assertNotEquals($expectedValue, $savedValue); $this->assertNotEquals($expectedValue, $savedValue);
} }