File tree Expand file tree Collapse file tree 2 files changed +16
-21
lines changed Expand file tree Collapse file tree 2 files changed +16
-21
lines changed Original file line number Diff line number Diff 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 ' );
Original file line number Diff line number Diff line change 55use Illuminate \Database \Eloquent \Model ;
66use 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- */
168class 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}
You can’t perform that action at this time.
0 commit comments