Skip to content

Commit bf64740

Browse files
fix tests
1 parent feeee8b commit bf64740

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

tests/Feature/EncryptedSearchIntegrationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,25 @@ protected function setUp(): void
5656
{
5757
parent::setUp();
5858

59+
// Configure in-memory SQLite database
5960
config()->set('database.default', 'testing');
6061
config()->set('database.connections.testing', [
6162
'driver' => 'sqlite',
6263
'database' => ':memory:',
6364
'prefix' => '',
6465
]);
6566

67+
// Disable Elasticsearch during tests (we test DB index)
68+
config()->set('encrypted-search.elasticsearch.enabled', false);
69+
70+
// Ensure Eloquent events are active (boot model & dispatcher)
71+
\Illuminate\Database\Eloquent\Model::unsetEventDispatcher();
72+
\Illuminate\Database\Eloquent\Model::setEventDispatcher(app('events'));
73+
74+
// Boot model traits manually for Testbench
75+
\Ginkelsoft\EncryptedSearch\Tests\Models\Client::boot();
76+
77+
// Create schema tables
6678
Schema::create('clients', function (Blueprint $table): void {
6779
$table->id();
6880
$table->string('first_names');

tests/Models/Client.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,14 @@
55
use Illuminate\Database\Eloquent\Model;
66
use Ginkelsoft\EncryptedSearch\Traits\HasEncryptedSearchIndex;
77

8-
/**
9-
* Class Client
10-
*
11-
* Minimal Eloquent model used for integration testing of
12-
* the Encrypted Search Index package.
13-
*
14-
* @package Ginkelsoft\EncryptedSearch\Tests\Models
15-
*/
168
class Client extends Model
179
{
1810
use HasEncryptedSearchIndex;
1911

20-
protected $table = 'clients';
2112
protected $fillable = ['first_names', 'last_names'];
2213

23-
/**
24-
* Define which fields should be indexed for encrypted search.
25-
*
26-
* @return array<string, array<string,bool>>
27-
*/
28-
public function getEncryptedSearchFields(): array
29-
{
30-
return [
31-
'first_names' => ['exact' => true, 'prefix' => true],
32-
'last_names' => ['exact' => true, 'prefix' => true],
33-
];
34-
}
14+
protected array $encryptedSearch = [
15+
'first_names' => ['exact' => true, 'prefix' => true],
16+
'last_names' => ['exact' => true, 'prefix' => true],
17+
];
3518
}

0 commit comments

Comments
 (0)