@@ -46,8 +46,7 @@ public function testReplicaConfig(): void
46
46
47
47
// Has created_at sort
48
48
$ this ->assertTrue (
49
- (bool )
50
- array_filter (
49
+ (bool ) array_filter (
51
50
$ sorting ,
52
51
function ($ sort ) use ($ sortAttr , $ sortDir ) {
53
52
return $ sort ['attribute ' ] == $ sortAttr
@@ -57,7 +56,7 @@ function($sort) use ($sortAttr, $sortDir) {
57
56
);
58
57
59
58
// Expected replica max
60
- $ this ->assertEquals ($ this ->replicaManager ->getMaxVirtualReplicasPerIndex (), 20 );
59
+ $ this ->assertEquals (20 , $ this ->replicaManager ->getMaxVirtualReplicasPerIndex ());
61
60
62
61
$ this ->indicesConfigurator ->saveConfigurationToAlgolia (1 );
63
62
$ this ->algoliaHelper ->waitLastTask ();
@@ -67,16 +66,26 @@ function($sort) use ($sortAttr, $sortDir) {
67
66
$ currentSettings = $ this ->algoliaHelper ->getSettings ($ indexName );
68
67
$ this ->assertArrayHasKey ('replicas ' , $ currentSettings );
69
68
69
+ $ sortIndexName = $ indexName . '_ ' . $ sortAttr . '_ ' . $ sortDir ;
70
+
70
71
$ this ->assertTrue (
71
- (bool )
72
- array_filter (
72
+ (bool ) array_filter (
73
73
$ currentSettings ['replicas ' ],
74
- function ($ replicaIndex ) use ($ indexName , $ sortAttr , $ sortDir ) {
75
- return str_contains ($ replicaIndex , $ indexName . ' _ ' . $ sortAttr . ' _ ' . $ sortDir );
74
+ function ($ replica ) use ($ sortIndexName ) {
75
+ return str_contains ($ replica , $ sortIndexName );
76
76
}
77
77
)
78
78
);
79
79
80
+ // Assert replica index created
81
+ $ replicaSettings = $ this ->algoliaHelper ->getSettings ($ sortIndexName );
82
+ $ this ->assertArrayHasKey ('primary ' , $ replicaSettings );
83
+ $ this ->assertEquals ($ indexName , $ replicaSettings ['primary ' ]);
84
+
85
+ // Assert standard replica ranking config
86
+ $ this ->assertArrayHasKey ('ranking ' , $ replicaSettings );
87
+ $ this ->assertContains ("$ sortDir( $ sortAttr) " , $ replicaSettings ['ranking ' ]);
88
+
80
89
}
81
90
82
91
public function tearDown (): void
0 commit comments