diff --git a/library/aik099/PHPUnit/BrowserTestCase.php b/library/aik099/PHPUnit/BrowserTestCase.php index 133e6fa..5a9c1ce 100644 --- a/library/aik099/PHPUnit/BrowserTestCase.php +++ b/library/aik099/PHPUnit/BrowserTestCase.php @@ -303,6 +303,10 @@ protected function tearDownTest() */ public function getCollectCodeCoverageInformation() { + if ( !$this->_remoteCoverageScriptUrl ) { + return false; + } + $result = $this->getTestResultObject(); if ( !is_object($result) ) { diff --git a/tests/aik099/PHPUnit/BrowserTestCaseTest.php b/tests/aik099/PHPUnit/BrowserTestCaseTest.php index d648731..101917f 100644 --- a/tests/aik099/PHPUnit/BrowserTestCaseTest.php +++ b/tests/aik099/PHPUnit/BrowserTestCaseTest.php @@ -274,11 +274,11 @@ protected function getBrowser($times) } /** - * Test description. + * @param string $remote_coverage_script_url Remote coverage script URL. * - * @return void + * @dataProvider getCollectCodeCoverageInformationSuccessDataProvider */ - public function testGetCollectCodeCoverageInformationSuccess() + public function testGetCollectCodeCoverageInformationSuccess($remote_coverage_script_url) { $test_case = $this->getFixture(); @@ -298,7 +298,22 @@ public function testGetCollectCodeCoverageInformationSuccess() $test_result->setCodeCoverage($code_coverage); $test_case->setTestResultObject($test_result); - $this->assertTrue($test_case->getCollectCodeCoverageInformation()); + // Failed. + if ( $remote_coverage_script_url ) { + $test_case->setRemoteCoverageScriptUrl($remote_coverage_script_url); + $this->assertTrue($test_case->getCollectCodeCoverageInformation()); + } + else { + $this->assertFalse($test_case->getCollectCodeCoverageInformation()); + } + } + + public function getCollectCodeCoverageInformationSuccessDataProvider() + { + return array( + 'with remote coverage url' => array('http://localhost/'), + 'without remote coverage url' => array(''), + ); } /** @@ -360,18 +375,12 @@ public function testRunWithCoverageWithoutRemoteUrl() )); $result->setCodeCoverage($code_coverage); - $test_id = $test_case->getTestId(); - $this->assertEmpty($test_id); + $this->assertEmpty($test_case->getTestId()); $browser = $test_case->getBrowser(); - $browser->shouldReceive('getBaseUrl')->once()->andReturn('A'); + $browser->shouldReceive('getBaseUrl')->never(); - $session = m::mock(Session::class); - $session->shouldReceive('visit')->with('A')->once(); - $session->shouldReceive('setCookie')->with(RemoteCoverageTool::TEST_ID_VARIABLE, null)->once(); - $session->shouldReceive('setCookie')->with(RemoteCoverageTool::TEST_ID_VARIABLE, m::not(''))->once(); - - $session_strategy->shouldReceive('session')->once()->andReturn($session); + $session_strategy->shouldReceive('session')->never(); $test_case->run($result); @@ -401,7 +410,7 @@ public function testRunWithCoverageWithoutRemoteUrl() $this->assertEquals($expected_coverage, $actual_coverage); } - $this->assertNotEmpty($test_case->getTestId()); + $this->assertEmpty($test_case->getTestId()); } /** diff --git a/tests/aik099/PHPUnit/Fixture/ApiIntegrationFixture.php b/tests/aik099/PHPUnit/Fixture/ApiIntegrationFixture.php index c83c3b6..227a5d0 100644 --- a/tests/aik099/PHPUnit/Fixture/ApiIntegrationFixture.php +++ b/tests/aik099/PHPUnit/Fixture/ApiIntegrationFixture.php @@ -152,15 +152,6 @@ public function verifyRemoteAPICalls() } } - /** - * @inheritDoc - */ - public function getCollectCodeCoverageInformation() - { - // FIXME: Workaround for https://github.com/minkphp/phpunit-mink/issues/35 bug. - return false; - } - /** * Test description. * diff --git a/tests/aik099/PHPUnit/Integration/BrowserStackAwareTestCase.php b/tests/aik099/PHPUnit/Integration/BrowserStackAwareTestCase.php index c0d6c1b..2cb17a8 100644 --- a/tests/aik099/PHPUnit/Integration/BrowserStackAwareTestCase.php +++ b/tests/aik099/PHPUnit/Integration/BrowserStackAwareTestCase.php @@ -37,18 +37,6 @@ protected function setUpTest() } } - /** - * Whatever or not code coverage information should be gathered. - * - * @return boolean - * @throws \RuntimeException When used before test is started. - */ - public function getCollectCodeCoverageInformation() - { - // FIXME: Workaround for https://github.com/minkphp/phpunit-mink/issues/35 bug. - return false; - } - /** * Gets browser configuration aliases. *