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

[stable29] fix(tests): Remove output when running tests #46290

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
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
15 changes: 15 additions & 0 deletions tests/lib/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ protected function setUp(): void {
$this->logger = new Log($this, $this->config, null, $this->registry);
}

private function mockDefaultLogLevel(): void {
$this->config->expects($this->any())
->method('getValue')
->will(($this->returnValueMap([
['loglevel', ILogger::WARN, ILogger::WARN],
])));
}

public function testInterpolation() {
$this->mockDefaultLogLevel();
$logger = $this->logger;
$logger->warning('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']);

Expand Down Expand Up @@ -69,6 +78,7 @@ public function testAppCondition() {
}

public function testLoggingWithDataArray(): void {
$this->mockDefaultLogLevel();
$writerMock = $this->createMock(IWriter::class);
$logFile = new Log($writerMock, $this->config);
$writerMock->expects($this->once())->method('write')->with('no app in context', ['something' => 'extra', 'message' => 'Testing logging with john']);
Expand Down Expand Up @@ -104,6 +114,7 @@ public function userAndPasswordData(): array {
* @dataProvider userAndPasswordData
*/
public function testDetectlogin(string $user, string $password): void {
$this->mockDefaultLogLevel();
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -126,6 +137,7 @@ public function testDetectlogin(string $user, string $password): void {
* @dataProvider userAndPasswordData
*/
public function testDetectcheckPassword(string $user, string $password): void {
$this->mockDefaultLogLevel();
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -148,6 +160,7 @@ public function testDetectcheckPassword(string $user, string $password): void {
* @dataProvider userAndPasswordData
*/
public function testDetectvalidateUserPass(string $user, string $password): void {
$this->mockDefaultLogLevel();
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -170,6 +183,7 @@ public function testDetectvalidateUserPass(string $user, string $password): void
* @dataProvider userAndPasswordData
*/
public function testDetecttryLogin(string $user, string $password): void {
$this->mockDefaultLogLevel();
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
Expand All @@ -192,6 +206,7 @@ public function testDetecttryLogin(string $user, string $password): void {
* @dataProvider userAndPasswordData
*/
public function testDetectclosure(string $user, string $password): void {
$this->mockDefaultLogLevel();
$a = function ($user, $password) {
throw new \Exception('test');
};
Expand Down
Loading