From eb56f6cc5f877e9b33697b765b6126cba9096739 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 14 Jan 2025 11:09:01 +0100 Subject: [PATCH] Test that with encrypted casts, the encrypted values are saved in the DB --- tests/VirtualColumnTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/VirtualColumnTest.php b/tests/VirtualColumnTest.php index 9808ad7..1bc9409 100644 --- a/tests/VirtualColumnTest.php +++ b/tests/VirtualColumnTest.php @@ -146,11 +146,14 @@ class VirtualColumnTest extends TestCase '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); }