11
11
use MongoDB \Driver \Exception \ServerException ;
12
12
use MongoDB \Laravel \Schema \Builder ;
13
13
use MongoDB \Laravel \Tests \TestCase ;
14
+ use PHPUnit \Framework \Attributes \Group ;
14
15
15
16
use function array_map ;
16
17
use function mt_getrandmax ;
19
20
use function srand ;
20
21
use function usleep ;
21
22
23
+ #[Group('atlas-search ' )]
22
24
class AtlasSearchTest extends TestCase
23
25
{
24
26
private array $ vectors ;
@@ -84,7 +86,7 @@ protected function setUp(): void
84
86
do {
85
87
$ ready = true ;
86
88
usleep (10_000 );
87
- foreach ($ collection ->listSearchIndexes () as $ index ) {
89
+ foreach ($ moviesCollection ->listSearchIndexes () as $ index ) {
88
90
if ($ index ['status ' ] !== 'READY ' ) {
89
91
$ ready = false ;
90
92
}
@@ -102,7 +104,7 @@ public function testSimpleSearch(): void
102
104
$ movies = Movie::search (
103
105
sort: ['title ' => 1 ],
104
106
operator: Search::text ('title ' , 'dream ' ),
105
- )->get ();
107
+ )->all ();
106
108
// end-search-query
107
109
108
110
$ this ->assertNotNull ($ movies );
@@ -113,10 +115,10 @@ public function testSimpleSearch(): void
113
115
* @runInSeparateProcess
114
116
* @preserveGlobalState disabled
115
117
*/
116
- public function autocompleteSearchTest (): void
118
+ public function testAutocompleteSearch (): void
117
119
{
118
120
// start-auto-query
119
- $ movies = Movie::autocomplete ('title ' , 'jak ' )->get ();
121
+ $ movies = Movie::autocomplete ('title ' , 'jak ' )->all ();
120
122
// end-auto-query
121
123
122
124
$ this ->assertNotNull ($ movies );
@@ -127,9 +129,9 @@ public function autocompleteSearchTest(): void
127
129
* @runInSeparateProcess
128
130
* @preserveGlobalState disabled
129
131
*/
130
- public function vectorSearchTest (): void
132
+ public function testVectorSearch (): void
131
133
{
132
- $ results = Book ::vectorSearch (
134
+ $ results = Movie ::vectorSearch (
133
135
index: 'vector ' ,
134
136
path: 'vector4 ' ,
135
137
queryVector: $ this ->vectors [0 ],
@@ -141,7 +143,7 @@ public function vectorSearchTest(): void
141
143
);
142
144
143
145
$ this ->assertNotNull ($ results );
144
- $ this ->assertSame ('C ' , $ results ->first ()->title );
146
+ $ this ->assertSame ('D ' , $ results ->first ()->title );
145
147
}
146
148
147
149
/** Generates random vectors using fixed seed to make tests deterministic */
0 commit comments