diff --git a/tests/VirtualColumnTest.php b/tests/VirtualColumnTest.php index 88db89f..8b55bbd 100644 --- a/tests/VirtualColumnTest.php +++ b/tests/VirtualColumnTest.php @@ -2,11 +2,12 @@ namespace Stancl\VirtualColumn\Tests; -use Stancl\VirtualColumn\Tests\Etc\EncryptedCast; use Orchestra\Testbench\TestCase; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Crypt; use Illuminate\Database\Eloquent\Model; use Stancl\VirtualColumn\VirtualColumn; +use Illuminate\Contracts\Database\Eloquent\CastsAttributes; class VirtualColumnTest extends TestCase { @@ -185,3 +186,26 @@ class FooModel extends Model return 'virtual'; } } + +class EncryptedCast implements CastsAttributes +{ + /** + * Cast the given value. + * + * @param array $attributes + */ + public function get(Model $model, string $key, mixed $value, array $attributes): mixed + { + return Crypt::decryptString($value); + } + + /** + * Prepare the given value for storage. + * + * @param array $attributes + */ + public function set(Model $model, string $key, mixed $value, array $attributes): mixed + { + return Crypt::encryptString($value); + } +} diff --git a/tests/etc/EncryptedCast.php b/tests/etc/EncryptedCast.php deleted file mode 100644 index ad61413..0000000 --- a/tests/etc/EncryptedCast.php +++ /dev/null @@ -1,30 +0,0 @@ - $attributes - */ - public function get(Model $model, string $key, mixed $value, array $attributes): mixed - { - return Crypt::decryptString($value); - } - - /** - * Prepare the given value for storage. - * - * @param array $attributes - */ - public function set(Model $model, string $key, mixed $value, array $attributes): mixed - { - return Crypt::encryptString($value); - } -}