File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -80,25 +80,32 @@ protected function loadFixtures(): void
8080 {
8181 $ baseDir = __DIR__ .'/fixtures/ ' ;
8282
83- foreach ($ this ->fixtures as $ fixture ) {
84- $ this ->loadFixture ($ baseDir .$ fixture );
83+ $ hasChanges = collect ($ this ->fixtures )
84+ ->reduce (
85+ fn (bool $ carry , string $ fixture ) => $ this ->loadFixture ($ baseDir .$ fixture ) || $ carry ,
86+ false
87+ );
88+
89+ if ($ hasChanges ) {
90+ $ this ->client ->indices ()->refresh (['index ' => $ this ->indexName ]);
8591 }
86-
87- sleep (1 );
8892 }
8993
90- protected function loadFixture (string $ path ): void
94+ protected function loadFixture (string $ path ): bool
9195 {
9296 $ documents = json_decode (file_get_contents ($ path ), true );
97+
9398 if (empty ($ documents )) {
94- return ;
99+ return false ;
95100 }
96101
97102 $ body = collect ($ documents )
98103 ->flatMap (fn (array $ document , int $ index ) => $ this ->documentToCommand ($ document , $ index ))
99104 ->toArray ();
100105
101106 $ this ->client ->bulk (['body ' => $ body ]);
107+
108+ return true ;
102109 }
103110
104111 protected function documentToCommand (array $ document , int $ id ): array
You can’t perform that action at this time.
0 commit comments