2020use Doctrine \ORM \Query ;
2121use Doctrine \ORM \Configuration ;
2222use Doctrine \ORM \EntityManager ;
23- use Doctrine \ORM \Event \LifecycleEventArgs ;
23+ use Doctrine \Persistence \Event \LifecycleEventArgs ;
2424use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
2525use Symfony \Component \Console \Application ;
2626use Symfony \Component \Console \Tester \CommandTester ;
3333 */
3434class TypesenseInteractionsTest extends KernelTestCase
3535{
36- public const NB_BOOKS = 5 ;
37- public const BOOK_TITLES = [
36+ public const int NB_BOOKS = 5 ;
37+ public const array BOOK_TITLES = [
3838 'Total Khéops ' ,
3939 'Chourmo ' ,
4040 'Solea ' ,
@@ -95,7 +95,7 @@ public function testImportCommand($nbBooks, $maxPerPage = null, $firstPage = nul
9595 );
9696 }
9797
98- public function importCommandProvider ()
98+ public function importCommandProvider (): array
9999 {
100100 return [
101101 "insert 10 books one by one " => [
@@ -105,7 +105,7 @@ public function importCommandProvider()
105105 42 , 10
106106 ],
107107 "insert 130 books 100 per 100 " => [
108- 130 , null //100 is by defaut
108+ 130 , null //100 is by default
109109 ],
110110 "insert 498 books 50 per 50, from page 8 to 10 and expect 148 inserted " => [
111111 498 , 50 , 8 , 10 , 148
@@ -129,12 +129,12 @@ public function testSearchByAuthor($nbBooks)
129129 $ bookFinder = new CollectionFinder ($ collectionClient , $ em , $ bookDefinition );
130130 $ query = new TypesenseQuery ('Nicolas ' , 'author ' );
131131
132- $ query ->maxHits ($ nbBooks < 250 ? $ nbBooks : 250 );
133- $ query ->perPage ($ nbBooks < 250 ? $ nbBooks : 250 );
132+ $ query ->maxHits (min ( $ nbBooks, 250 ) );
133+ $ query ->perPage (min ( $ nbBooks, 250 ) );
134134
135135 $ results = $ bookFinder ->rawQuery ($ query )->getResults ();
136136
137- self ::assertCount (($ nbBooks < 250 ? $ nbBooks : 250 ), $ results , "result doesn't contains " .$ nbBooks .' elements ' );
137+ self ::assertCount ((min ( $ nbBooks, 250 ) ), $ results , "result doesn't contains " .$ nbBooks .' elements ' );
138138 self ::assertArrayHasKey ('document ' , $ results [0 ], "First item does not have the key 'document' " );
139139 self ::assertArrayHasKey ('highlights ' , $ results [0 ], "First item does not have the key 'highlights' " );
140140 self ::assertArrayHasKey ('text_match ' , $ results [0 ], "First item does not have the key 'text_match' " );
@@ -284,7 +284,7 @@ private function importCommandTester($options): CommandTester
284284 return new CommandTester ($ application ->find ('typesense:import ' ));
285285 }
286286
287- private function getCollectionDefinitions ($ entityClass )
287+ private function getCollectionDefinitions ($ entityClass ): array
288288 {
289289 return [
290290 'books ' => [
@@ -343,7 +343,7 @@ private function getCollectionDefinitions($entityClass)
343343 ];
344344 }
345345
346- private function getMockedBooks ($ options )
346+ private function getMockedBooks ($ options ): array
347347 {
348348 $ author = new Author ('Nicolas Potier ' , 'France ' );
349349 $ books = [];
0 commit comments