From 9594cd085743cc1cdfbfdcccec9ef7471e5970b7 Mon Sep 17 00:00:00 2001 From: Nick Schaller Date: Sun, 7 Apr 2024 14:25:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20a=20test=20for=20a=20null?= =?UTF-8?q?=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/VirtualColumnTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/VirtualColumnTest.php b/tests/VirtualColumnTest.php index bb33458..9808ad7 100644 --- a/tests/VirtualColumnTest.php +++ b/tests/VirtualColumnTest.php @@ -143,13 +143,16 @@ class VirtualColumnTest extends TestCase 'json' => json_encode(['foo', 'bar']), // 'encrypted:json' 'object' => (object) json_encode(['foo', 'bar']), // 'encrypted:object' 'custom' => 'foo', // Custom castable – 'EncryptedCast::class' + 'null_value' => null, // 'encrypted' ]); foreach($encryptedAttributes as $key => $expectedValue) { $savedValue = $model->getAttributes()[$key]; // Encrypted - $this->assertTrue($model->valueEncrypted($savedValue)); - $this->assertNotEquals($expectedValue, $savedValue); + if ($savedValue !== null) { + $this->assertTrue($model->valueEncrypted($savedValue)); + $this->assertNotEquals($expectedValue, $savedValue); + } $retrievedValue = $model->$key; // Decrypted @@ -178,6 +181,7 @@ class MyModel extends ParentModel 'json' => 'encrypted:json', 'object' => 'encrypted:object', 'custom' => EncryptedCast::class, + 'null_value' => 'encrypted', ]; }