Skip to content

Commit

Permalink
Merge pull request #46284 from nextcloud/bugfix/noid/fix-output-when-…
Browse files Browse the repository at this point in the history
…running-unit-tests

fix(tests): Remove output when running tests
  • Loading branch information
AndyScherzinger authored Jul 3, 2024
2 parents 599b86a + a1d3b5f commit 40fb16b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/lib/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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 @@ -65,6 +74,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 @@ -100,6 +110,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 @@ -122,6 +133,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 @@ -144,6 +156,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 @@ -166,6 +179,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 @@ -188,6 +202,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

0 comments on commit 40fb16b

Please sign in to comment.