mirror of
https://github.com/archtechx/virtualcolumn.git
synced 2025-12-12 14:04:02 +00:00
🧪 Add a test for a null value
This commit is contained in:
parent
7371aac2ab
commit
9594cd0857
1 changed files with 6 additions and 2 deletions
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue