Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-fix isset check and revert PR #539 #546

Merged
merged 5 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add test coverage for shouldSuppress()
Exposes the bug indicated by PR #539.
  • Loading branch information
Bishop Bettini committed Nov 8, 2021
commit fc9eb8025bbe289eb80fe741fbe093ca39e48b4d
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ private function levelTooLow(Level $level): bool
return $level->toInt() < $this->minimumLevel;
}

private function shouldSuppress(): bool
public function shouldSuppress(): bool
{
return error_reporting() === 0 && !$this->reportSuppressed;
}
Expand Down
34 changes: 31 additions & 3 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,37 @@ private function prepareMockPayload($level)
return new Payload($data, $this->getTestAccessToken());
}

public function testReportSuppressed()
{
$this->assertTrue(true, "Don't know how to unit test this. PRs welcome");
/**
* Test the shouldSuppress method, which is driven by the configuration
* given and the value of the PHP engine's error_reporting() setting.
*
* - error reporting value
* | - configuration key
* | | - configuration value
* | | | - shouldSuppress() result
* v v v v
* @testWith [0, "reportSuppressed", false, true]
* [0, "reportSuppressed", true, false]
* [1, "reportSuppressed", false, false]
* [0, "report_suppressed", false, true]
* [0, "report_suppressed", true, false]
* [1, "report_suppressed", false, false]
*/
public function testReportSuppressed($errorReporting, $configKey, $configValue, $shouldSuppressExpect)
{
$oldErrorReporting = error_reporting($errorReporting);
try {
$config = new Config(array(
$configKey => $configValue
));
$this->assertSame(
$shouldSuppressExpect,
$config->shouldSuppress(),
'shouldSuppress() did not return the expected value for the error_reporting and configuration given'
);
} finally {
error_reporting($oldErrorReporting);
}
}

public function testFilter()
Expand Down