4
4
5
5
use MongoDB \Model \CachingIterator ;
6
6
use MongoDB \Tests \FunctionalTestCase ;
7
+ use MongoDB \Tests \TestCase ;
7
8
8
9
use function bin2hex ;
9
- use function getenv ;
10
10
use function preg_match ;
11
11
use function random_bytes ;
12
12
use function sleep ;
@@ -19,22 +19,15 @@ class SearchIndexFunctionalTest extends FunctionalTestCase
19
19
{
20
20
private const ATLAS_TLD = '/\.(mongodb\.net|mongodb-dev\.net)/ ' ;
21
21
22
- /**
23
- * Connect to a MongoDB Atlas Server.
24
- */
25
22
public static function getUri ($ allowMultipleMongoses = false ): string
26
23
{
27
- $ atlasUri = getenv ('MONGODB_ATLAS_URI ' );
28
-
29
- if (! $ atlasUri ) {
30
- self ::markTestSkipped ('MONGODB_ATLAS_URI environment variable is not set ' );
31
- }
24
+ $ uri = TestCase::getUri ();
32
25
33
- if (! preg_match (self ::ATLAS_TLD , $ atlasUri )) {
34
- self ::fail ( ' MONGODB_ATLAS_URI is not an Atlas URI ' );
26
+ if (! preg_match (self ::ATLAS_TLD , $ uri )) {
27
+ self ::markTestSkipped ( ' Search Indexes are only supported on MongoDB Atlas ' );
35
28
}
36
29
37
- return $ atlasUri ;
30
+ return $ uri ;
38
31
}
39
32
40
33
public function testCreateSearchIndexesWithEmptyList (): void
@@ -53,6 +46,9 @@ public function testCreateSearchIndexWithDefaultName(): void
53
46
$ this ->assertSame ('default ' , $ name );
54
47
}
55
48
49
+ /**
50
+ * This test can take up to 3 minutes to finish. Search index management are async operations.
51
+ */
56
52
public function testIndexLifecycle (): void
57
53
{
58
54
$ collection = $ this ->createCollection ($ this ->getDatabaseName (), $ this ->getCollectionName ());
@@ -63,7 +59,7 @@ public function testIndexLifecycle(): void
63
59
$ this ->assertSame ($ name , $ createdName );
64
60
65
61
// Wait for the index to be ready
66
- $ maxWaitingTime = 90 ;
62
+ $ maxWaitingTime = 120 ;
67
63
do {
68
64
sleep (1 );
69
65
$ result = $ collection ->listSearchIndexes ($ name );
0 commit comments