2929
3030class IndexerTest extends TestCase
3131{
32- public static function setUpBeforeClass ()
32+ public static function setUpBeforeClass (): void
3333 {
3434 global $ APPLICATION ;
3535
3636 self ::tearDownAfterClass ();
3737
38+ $ elements = CIBlockElement::GetList (['ID ' => 'ASC ' ]);
39+ while ($ element = $ elements ->Fetch ()) {
40+ CIBlockElement::Delete ($ element ['ID ' ]);
41+ }
42+
3843 $ cIBlockType = new CIBlockType ();
3944 $ isTypeAdded = $ cIBlockType ->Add ([
4045 'ID ' => 'elastic_test ' ,
@@ -138,7 +143,7 @@ public static function setUpBeforeClass()
138143 'TITLE ' => 'Основной склад ' ,
139144 'XML_ID ' => 'MAIN ' ,
140145 'ACTIVE ' => 'Y ' ,
141- 'ADDRESS ' => '' ,
146+ 'ADDRESS ' => 'Липецк ' ,
142147 'DESCRIPTION ' => ''
143148 ]);
144149
@@ -148,7 +153,7 @@ public static function setUpBeforeClass()
148153 'TITLE ' => 'Запасной склад ' ,
149154 'XML_ID ' => 'SECONDARY ' ,
150155 'ACTIVE ' => 'Y ' ,
151- 'ADDRESS ' => '' ,
156+ 'ADDRESS ' => 'Тамбов ' ,
152157 'DESCRIPTION ' => ''
153158 ]);
154159
@@ -287,7 +292,7 @@ public static function setUpBeforeClass()
287292 fclose ($ csv );
288293 }
289294
290- public static function tearDownAfterClass ()
295+ public static function tearDownAfterClass (): void
291296 {
292297 CIBlockType::Delete ('elastic_test ' );
293298
@@ -728,15 +733,15 @@ public function testCanSearch(array $stack = [])
728733 ];
729734
730735 foreach ($ filters as $ filter ) {
731- $ response = $ indexer ->search ('test_products ' , $ filter );
736+ $ response = $ indexer ->search ('test_products ' , $ filter, [ ' ID ' => ' ASC ' ], [ ' size ' => 20 ] );
732737 $ this ->assertNotEmpty ($ response ['hits ' ]['hits ' ], 'No elasticsearch hits for ' . json_encode ($ filter ));
733738
734739 $ elasticIds = array_map (function ($ hit ) {
735740 return (int )$ hit ['_source ' ]['ID ' ];
736741 }, $ response ['hits ' ]['hits ' ]);
737742
738743 $ elements = [];
739- $ rs = CIBlockElement::GetList (null , $ filter );
744+ $ rs = CIBlockElement::GetList ([ ' ID ' => ' ASC ' ] , $ filter );
740745 while ($ element = $ rs ->GetNextElement ()) {
741746 $ elements [] = $ element ;
742747 }
@@ -749,8 +754,8 @@ public function testCanSearch(array $stack = [])
749754 }, $ elements );
750755
751756 $ this ->assertSame (
752- array_slice (sort ( $ bitrixIds) , 0 , 10 ),
753- array_slice (sort ( $ elasticIds) , 0 , 10 )
757+ array_slice ($ bitrixIds , 0 , 20 ),
758+ array_slice ($ elasticIds , 0 , 20 )
754759 );
755760 }
756761
0 commit comments