Skip to content

Commit 8856e2e

Browse files
author
Yoke DV9
committed
Fix test case
1 parent f85177b commit 8856e2e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Traits/EncryptedAttribute.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010

1111
trait EncryptedAttribute {
1212

13+
public static $enableEncryption = true;
14+
15+
function __construct() {
16+
self::$enableEncryption = config('laravelDatabaseEncryption.enable_encryption');
17+
}
18+
1319
/**
1420
* @param $key
1521
* @return bool
1622
*/
1723
public function isEncryptable($key)
1824
{
19-
if(config('laravelDatabaseEncryption.enable_encryption')){
25+
if(self::$enableEncryption){
2026
return in_array($key, $this->encryptable);
2127
}
2228

tests/Unit/EncryptedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ public function it_test_that_validation_rule_unique_when_record_does_not_exists_
147147
/**
148148
* @test
149149
*/
150-
public function it_tests_that_empty_values_are_encrypted()
150+
public function it_tests_that_empty_values_are_not_encrypted()
151151
{
152152
$user = $this->createUser(null, 'example@email.com');
153153
$raw = DB::table('test_users')->select('*')->first();
154154

155-
$this->assertNotEmpty($raw->name);
155+
$this->assertEmpty($raw->name);
156156
$this->assertEmpty($user->name);
157157
}
158158

tests/database/migrations/2018_09_29_000001_create_test_users_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('test_users', function (Blueprint $table) {
1616
$table->increments('id');
17-
$table->string('name');
17+
$table->string('name')->nullable();
1818
$table->string('email')->unique();
1919
$table->string('password');
2020
$table->rememberToken();

0 commit comments

Comments
 (0)