diff --git a/tests/e2e/Example_Test/infection.json b/tests/e2e/Example_Test/infection.json index 78f1cefb18..a5d873d673 100644 --- a/tests/e2e/Example_Test/infection.json +++ b/tests/e2e/Example_Test/infection.json @@ -7,10 +7,7 @@ ] }, "logs": { - "summary": "infection.log", - "stryker": { - "badge": "feature/stryker-setting" - } + "summary": "infection.log" }, "tmpDir": "." } diff --git a/tests/phpunit/Logger/StrykerLoggerTest.php b/tests/phpunit/Logger/StrykerLoggerTest.php index c52659b557..78b648e8d0 100644 --- a/tests/phpunit/Logger/StrykerLoggerTest.php +++ b/tests/phpunit/Logger/StrykerLoggerTest.php @@ -98,8 +98,6 @@ protected function setUp(): void StrykerConfig::forBadge('master'), $this->logger ); - - // todo add forFullReport cases } protected function tearDown(): void @@ -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() + ); + } }