Skip to content

Commit

Permalink
Add more tests, remove todo
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed Dec 27, 2021
1 parent a8654d1 commit 2b4e6de
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
5 changes: 1 addition & 4 deletions tests/e2e/Example_Test/infection.json
Expand Up @@ -7,10 +7,7 @@
]
},
"logs": {
"summary": "infection.log",
"stryker": {
"badge": "feature/stryker-setting"
}
"summary": "infection.log"
},
"tmpDir": "."
}
48 changes: 46 additions & 2 deletions tests/phpunit/Logger/StrykerLoggerTest.php
Expand Up @@ -98,8 +98,6 @@ protected function setUp(): void
StrykerConfig::forBadge('master'),
$this->logger
);

// todo add forFullReport cases
}

protected function tearDown(): void
Expand Down Expand Up @@ -427,4 +425,50 @@ public function test_it_sends_report_when_everything_is_ok_with_our_key(): void
$this->logger->getLogs()
);
}

public function test_it_sends_report_when_everything_is_ok_with_our_key_for_full_report(): void
{
$this->strykerLogger = new StrykerLogger(
new BuildContextResolver(CiDetector::fromEnvironment($this->ciDetectorEnv)),
new StrykerApiKeyResolver(),
$this->strykerDashboardClient,
$this->metricsCalculatorMock,
new StrykerHtmlReportBuilder($this->metricsCalculatorMock, new ResultsCollector()),
StrykerConfig::forFullReport('master'),
$this->logger
);

$this->ciDetectorEnv->setVariables([
'TRAVIS' => 'true',
'TRAVIS_PULL_REQUEST' => 'false',
'TRAVIS_REPO_SLUG' => 'a/b',
'TRAVIS_BRANCH' => 'master',
]);

putenv('INFECTION_DASHBOARD_API_KEY=abc');

$this->strykerDashboardClient
->expects($this->once())
->method('sendReport')
->with('github.com/a/b', 'master', 'abc', '{"schemaVersion":"1","thresholds":{"high":90,"low":50},"files":{},"testFiles":{},"framework":{"name":"Infection","branding":{"homepageUrl":"https:\/\/infection.github.io\/","imageUrl":"https:\/\/infection.github.io\/images\/logo.png"}}}')
;

$this->metricsCalculatorMock
->method('getMutationScoreIndicator')
->willReturn(33.3)
;

$this->strykerLogger->log();

$this->assertSame(
[
[
LogLevel::WARNING,
'Sending dashboard report...',
[],
],
],
$this->logger->getLogs()
);
}
}

0 comments on commit 2b4e6de

Please sign in to comment.