@@ -382,26 +382,50 @@ class Tester
382382 * @return null|array
383383 * @throws \Exception
384384 */
385- public function testConfig ($ silent = false )
385+ public function testConfig ($ silent = false , array | string | null $ expectedPattern = null ): ? array
386386 {
387387 $ configFile = $ this ->createConfig ();
388388 $ cmd = self ::findExecutable () . ' -n -tt -y ' . $ configFile . ' 2>&1 ' ;
389389 $ this ->trace ('Testing config using command ' , $ cmd , true );
390390 exec ($ cmd , $ output , $ code );
391+ $ found = 0 ;
392+ if ($ expectedPattern !== null ) {
393+ $ expectedPatterns = is_array ($ expectedPattern ) ? $ expectedPattern : [$ expectedPattern ];
394+ }
391395 if ($ code ) {
392396 $ messages = [];
393397 foreach ($ output as $ outputLine ) {
394398 $ message = preg_replace ("/\[.+?\]/ " , "" , $ outputLine , 1 );
399+ if ($ expectedPattern !== null ) {
400+ for ($ i = 0 ; $ i < count ($ expectedPatterns ); $ i ++) {
401+ $ pattern = $ expectedPatterns [$ i ];
402+ if ($ pattern !== null && preg_match ($ pattern , $ message )) {
403+ $ found ++;
404+ $ expectedPatterns [$ i ] = null ;
405+ }
406+ }
407+ }
395408 $ messages [] = $ message ;
396409 if ( ! $ silent ) {
397410 $ this ->error ($ message , null , false );
398411 }
399412 }
413+ } else {
414+ $ messages = null ;
415+ }
400416
401- return $ messages ;
417+ if ($ expectedPattern !== null && $ found < count ($ expectedPatterns )) {
418+ $ missingPatterns = array_filter ($ expectedPatterns );
419+ $ errorMessage = sprintf (
420+ "The expected config %s %s %s not been found " ,
421+ count ($ missingPatterns ) > 1 ? 'patterns ' : 'pattern ' ,
422+ implode (', ' , $ missingPatterns ),
423+ count ($ missingPatterns ) > 1 ? 'have ' : 'has ' ,
424+ );
425+ $ this ->error ($ errorMessage );
402426 }
403427
404- return null ;
428+ return $ messages ;
405429 }
406430
407431 /**
@@ -1155,9 +1179,19 @@ class Tester
11551179 return $ address ;
11561180 }
11571181
1158- return sys_get_temp_dir () . '/ ' .
1159- hash ('crc32 ' , dirname ($ address )) . '- ' .
1160- basename ($ address );
1182+ $ addressPart = hash ('crc32 ' , dirname ($ address )) . '- ' . basename ($ address );
1183+
1184+ // is longer on Mac, than on Linux
1185+ $ tmpDirAddress = sys_get_temp_dir () . '/ ' . $ addressPart ;
1186+ ;
1187+
1188+ if (strlen ($ tmpDirAddress ) <= 104 ) {
1189+ return $ tmpDirAddress ;
1190+ }
1191+
1192+ $ srcRootAddress = dirname (__DIR__ , 3 ) . '/ ' . $ addressPart ;
1193+
1194+ return $ srcRootAddress ;
11611195 }
11621196
11631197 return $ this ->getHost ($ type ) . ': ' . $ port ;
0 commit comments