Skip to content

Commit

Permalink
Improved TestFailureData::exception*ContainsFragment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Feb 17, 2025
1 parent 397b67f commit 0248e81
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/Core/Log/Failure/TestFailureData.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,18 @@ public function applicationLogContainsFragment($logFragment)
return false;
}

public function exceptionStackTraceContainsFragment(string $stackTraceFragment)
public function exceptionStackTraceContainsFragment(string $stackTraceFragment): bool
{
return strpos($this->getFailedStepsResult()->getException()->getTraceAsString(), $stackTraceFragment) !== false;
$throwable = $this->getFailedStepsResult()->getException();

return $throwable !== null && strpos($throwable->getTraceAsString(), $stackTraceFragment) !== false;
}

public function exceptionMessageContainsFragment(string $exceptionMessageFragment)
public function exceptionMessageContainsFragment(string $exceptionMessageFragment): bool
{
$exceptionMessage = $this->getFailedStepsResult()->getException()->getMessage();
$throwable = $this->getFailedStepsResult()->getException();

return strpos($exceptionMessage, $exceptionMessageFragment) !== false;
return $throwable !== null && strpos($throwable->getMessage(), $exceptionMessageFragment) !== false;
}

public function browserLogsContainFragment(string $logFragment)
Expand Down

0 comments on commit 0248e81

Please sign in to comment.