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 @@ -81,25 +81,32 @@ protected function loadFixtures(): void
8181 {
8282 $ baseDir = __DIR__ .'/fixtures/ ' ;
8383
84- foreach ($ this ->fixtures as $ fixture ) {
85- $ this ->loadFixture ($ baseDir .$ fixture );
84+ $ hasChanges = collect ($ this ->fixtures )
85+ ->reduce (
86+ fn (bool $ carry , string $ fixture ) => $ this ->loadFixture ($ baseDir .$ fixture ) || $ carry ,
87+ false
88+ );
89+
90+ if ($ hasChanges ) {
91+ $ this ->client ->indices ()->refresh (['index ' => $ this ->indexName ]);
8692 }
87-
88- sleep (1 );
8993 }
9094
91- protected function loadFixture (string $ path ): void
95+ protected function loadFixture (string $ path ): bool
9296 {
9397 $ documents = json_decode (file_get_contents ($ path ), true );
98+
9499 if (empty ($ documents )) {
95- return ;
100+ return false ;
96101 }
97102
98103 $ body = collect ($ documents )
99104 ->flatMap (fn (array $ document , int $ index ) => $ this ->documentToCommand ($ document , $ index ))
100105 ->toArray ();
101106
102107 $ this ->client ->bulk (['body ' => $ body ]);
108+
109+ return true ;
103110 }
104111
105112 protected function documentToCommand (array $ document , int $ id ): array
You can’t perform that action at this time.
0 commit comments