From 3213a8e85636d1cac073d769e1ff684e765451d0 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 7 Aug 2023 17:42:38 +0200 Subject: [PATCH] Add encrypted casts test (wip) --- tests/VirtualColumnTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/VirtualColumnTest.php b/tests/VirtualColumnTest.php index 247b189..1766f87 100644 --- a/tests/VirtualColumnTest.php +++ b/tests/VirtualColumnTest.php @@ -106,6 +106,19 @@ class VirtualColumnTest extends TestCase } // 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 @@ -114,6 +127,9 @@ class MyModel extends Model protected $guarded = []; public $timestamps = false; + public $casts = [ + 'password' + ]; public static function getCustomColumns(): array {