Skip to content

Commit

Permalink
Test that with encrypted casts, the encrypted values are saved in the DB
Browse files Browse the repository at this point in the history
  • Loading branch information
lukinovec committed Jan 14, 2025
1 parent 65f9000 commit eb56f6c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/VirtualColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,14 @@ public function encrypted_casts_work_with_virtual_column() {
'null_value' => null, // 'encrypted'
]);

$databaseRecord = json_decode(DB::select('SELECT data FROM my_models')[0]->data);

foreach($encryptedAttributes as $key => $expectedValue) {
$savedValue = $model->getAttributes()[$key]; // Encrypted

if ($savedValue !== null) {
$this->assertTrue($model->valueEncrypted($savedValue));
$this->assertEquals($savedValue, $databaseRecord->$key); // Encrypted in DB
$this->assertNotEquals($expectedValue, $savedValue);
}

Expand Down

0 comments on commit eb56f6c

Please sign in to comment.