@@ -98,4 +98,46 @@ public function testSearchImportAggregator()
98
98
$ this ->assertStringContainsString ('Done! ' , $ output );
99
99
$ this ->assertSame (0 , $ return );
100
100
}
101
+
102
+ public function testImportingIndexNameWithAndWithoutPrefix (): void
103
+ {
104
+ for ($ i = 0 ; $ i <= 5 ; ++$ i ) {
105
+ $ this ->createPost ();
106
+ }
107
+
108
+ $ command = $ this ->application ->find ('meili:import ' );
109
+ $ commandTester = new CommandTester ($ command );
110
+ $ return = $ commandTester ->execute ([
111
+ '--indices ' => $ this ->index ->getUid (), // This is the already prefixed name
112
+ ]);
113
+
114
+ $ output = $ commandTester ->getDisplay ();
115
+ $ this ->assertStringContainsString ('Importing for index MeiliSearch\Bundle\Test\Entity\Post ' , $ output );
116
+ $ this ->assertStringContainsString ('Indexed ' .$ i .' / ' .$ i .' MeiliSearch\Bundle\Test\Entity\Post entities into sf_phpunit__ ' .self ::$ indexName .' index ' , $ output );
117
+ $ this ->assertStringContainsString ('Done! ' , $ output );
118
+ $ this ->assertSame (0 , $ return );
119
+
120
+ // Reset database and MS indexes
121
+ parent ::setUp ();
122
+
123
+ for ($ i = 0 ; $ i <= 5 ; ++$ i ) {
124
+ $ this ->createPost ();
125
+ }
126
+
127
+ $ command = $ this ->application ->find ('meili:import ' );
128
+ $ commandTester = new CommandTester ($ command );
129
+ $ return = $ commandTester ->execute ([
130
+ '--indices ' => self ::$ indexName , // This is the already prefixed name
131
+ ]);
132
+
133
+ // Check that the same index like above is created with the same name, although we passed it
134
+ // in without the prefix
135
+ $ this ->assertInstanceOf (Indexes::class, $ this ->index ->fetchInfo ());
136
+
137
+ $ output = $ commandTester ->getDisplay ();
138
+ $ this ->assertStringContainsString ('Importing for index MeiliSearch\Bundle\Test\Entity\Post ' , $ output );
139
+ $ this ->assertStringContainsString ('Indexed ' .$ i .' / ' .$ i .' MeiliSearch\Bundle\Test\Entity\Post entities into sf_phpunit__ ' .self ::$ indexName .' index ' , $ output );
140
+ $ this ->assertStringContainsString ('Done! ' , $ output );
141
+ $ this ->assertSame (0 , $ return );
142
+ }
101
143
}
0 commit comments