1
0
Fork 0
mirror of https://github.com/archtechx/virtualcolumn.git synced 2025-12-12 17:24:03 +00:00

Add encrypted casts test (wip)

This commit is contained in:
lukinovec 2023-08-07 17:42:38 +02:00
parent 0b108903b5
commit 3213a8e856

View file

@ -106,6 +106,19 @@ class VirtualColumnTest extends TestCase
} }
// maybe add an explicit test that the saving() and updating() listeners don't run twice? // maybe add an explicit test that the saving() and updating() listeners don't run twice?
/** @test */
public function encrypted_casts_work_with_virtual_column() {
$model = MyModel::create(['password' => $password = 'foo']);
// Virtual column gets encrypted
// todo1 check what value actually got saved in $model->password (should be encrypted 'foo')
// Virtual column gets decrypted
$this->assertSame($model->password, $password);
// todo1 Check if *all* encrypted casts work
}
} }
class MyModel extends Model class MyModel extends Model
@ -114,6 +127,9 @@ class MyModel extends Model
protected $guarded = []; protected $guarded = [];
public $timestamps = false; public $timestamps = false;
public $casts = [
'password'
];
public static function getCustomColumns(): array public static function getCustomColumns(): array
{ {