@@ -392,60 +392,31 @@ public function assertEventTriggered(string $eventName): bool
392
392
}
393
393
394
394
/**
395
- * Hooks into xdebug's headers capture, looking for a specific header
396
- * emitted
395
+ * Hooks into xdebug's headers capture, looking for presence of
396
+ * a specific header emitted.
397
397
*
398
398
* @param string $header The leading portion of the header we are looking for
399
- *
400
- * @throws Exception
401
399
*/
402
400
public function assertHeaderEmitted (string $ header , bool $ ignoreCase = false ): void
403
401
{
404
- $ found = false ;
405
-
406
- if (! function_exists ('xdebug_get_headers ' )) {
407
- $ this ->markTestSkipped ('XDebug not found. ' );
408
- }
409
-
410
- foreach (xdebug_get_headers () as $ emitted ) {
411
- $ found = $ ignoreCase ?
412
- (stripos ($ emitted , $ header ) === 0 ) :
413
- (strpos ($ emitted , $ header ) === 0 );
414
- if ($ found ) {
415
- break ;
416
- }
417
- }
418
-
419
- $ this ->assertTrue ($ found , "Didn't find header for {$ header }" );
402
+ $ this ->assertTrue (
403
+ $ this ->getHeaderEmitted ($ header , $ ignoreCase ) !== null ,
404
+ "Didn't find header for {$ header }"
405
+ );
420
406
}
421
407
422
408
/**
423
- * Hooks into xdebug's headers capture, looking for a specific header
424
- * emitted
409
+ * Hooks into xdebug's headers capture, looking for absence of
410
+ * a specific header emitted.
425
411
*
426
412
* @param string $header The leading portion of the header we don't want to find
427
- *
428
- * @throws Exception
429
413
*/
430
414
public function assertHeaderNotEmitted (string $ header , bool $ ignoreCase = false ): void
431
415
{
432
- $ found = false ;
433
-
434
- if (! function_exists ('xdebug_get_headers ' )) {
435
- $ this ->markTestSkipped ('XDebug not found. ' );
436
- }
437
-
438
- foreach (xdebug_get_headers () as $ emitted ) {
439
- $ found = $ ignoreCase ?
440
- (stripos ($ emitted , $ header ) === 0 ) :
441
- (strpos ($ emitted , $ header ) === 0 );
442
- if ($ found ) {
443
- break ;
444
- }
445
- }
446
-
447
- $ success = ! $ found ;
448
- $ this ->assertTrue ($ success , "Found header for {$ header }" );
416
+ $ this ->assertTrue (
417
+ $ this ->getHeaderEmitted ($ header , $ ignoreCase ) === null ,
418
+ "Found header for {$ header }"
419
+ );
449
420
}
450
421
451
422
/**
@@ -528,15 +499,16 @@ protected function createApplication()
528
499
protected function getHeaderEmitted (string $ header , bool $ ignoreCase = false ): ?string
529
500
{
530
501
if (! function_exists ('xdebug_get_headers ' )) {
531
- $ this ->markTestSkipped ('XDebug not found. ' );
502
+ $ this ->markTestSkipped ('xdebug not found. ' );
532
503
}
533
504
534
- foreach (xdebug_get_headers () as $ emitted ) {
535
- $ found = $ ignoreCase ?
536
- (stripos ($ emitted , $ header ) === 0 ) :
537
- (strpos ($ emitted , $ header ) === 0 );
505
+ foreach (xdebug_get_headers () as $ emittedHeader ) {
506
+ $ found = $ ignoreCase
507
+ ? (stripos ($ emittedHeader , $ header ) === 0 )
508
+ : (strpos ($ emittedHeader , $ header ) === 0 );
509
+
538
510
if ($ found ) {
539
- return $ emitted ;
511
+ return $ emittedHeader ;
540
512
}
541
513
}
542
514
0 commit comments