-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the LGPL. For more information please see | ||
* <http://phing.info>. | ||
*/ | ||
|
||
/** | ||
* @author Siad Ardroumli <siad.ardroumli@gmail.com> | ||
* @package phing.tasks.ext | ||
*/ | ||
class CoverageMergeTest extends BuildFileTest | ||
{ | ||
public function setUp(): void | ||
{ | ||
if (!file_exists(PHING_TEST_BASE . "/etc/tasks/ext/coverage/workspace")) { | ||
mkdir(PHING_TEST_BASE . "/etc/tasks/ext/coverage/workspace"); | ||
} | ||
$this->configureProject(PHING_TEST_BASE . "/etc/tasks/ext/coverage/build.xml"); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
$this->rmdir(PHING_TEST_BASE . "/etc/tasks/ext/coverage/workspace"); | ||
} | ||
|
||
public function testCoverage(): void | ||
{ | ||
$workspace = PHING_TEST_BASE . "/etc/tasks/ext/coverage/workspace"; | ||
$this->executeTarget('collect'); | ||
$this->assertFileExists($workspace . '/1/clover-coverage.xml'); | ||
$this->assertFileExists($workspace . '/2/clover-coverage.xml'); | ||
$this->assertFileExists($workspace . '/3/clover-coverage.xml'); | ||
$this->assertFileExists($workspace . '/output.xml'); | ||
$this->assertFileExists($workspace . '/test.db'); | ||
$this->assertFileExists($workspace . '/test-results1.xml'); | ||
$this->assertFileExists($workspace . '/test-results2.xml'); | ||
$this->assertFileExists($workspace . '/test-results3.xml'); | ||
$this->assertStringContainsString('Dummy1Test.php', file_get_contents($workspace . '/test.db')); | ||
$this->assertStringContainsString('Dummy2Test.php', file_get_contents($workspace . '/test.db')); | ||
$this->assertStringContainsString('Dummy3Test.php', file_get_contents($workspace . '/test.db')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0"?> | ||
|
||
<!-- | ||
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
~ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
~ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
~ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
~ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
~ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
~ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
~ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
~ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
~ | ||
~ This software consists of voluntary contributions made by many individuals | ||
~ and is licensed under the LGPL. For more information please see | ||
~ <http://phing.info>. | ||
--> | ||
|
||
<project name="Coverage Build Tests" default="main" basedir="."> | ||
<resolvepath propertyName="workspace" path="${phing.dir}/workspace" /> | ||
<property name="test" value="${workspace}/test.db" /> | ||
<property name="output" value="${workspace}/output.xml" /> | ||
|
||
<target name="collect"> | ||
<coverage-setup database="${test}"> | ||
<fileset dir="${phing.dir}" includes="**/test/*"/> | ||
</coverage-setup> | ||
<phpunit codecoverage="true"> | ||
<formatter type="xml" todir="${workspace}" outfile="test-results1.xml"/> | ||
<formatter type="clover" todir="${workspace}/1"/> | ||
<formatter type="plain" usefile="false"/> | ||
<batchtest> | ||
<fileset dir="${phing.dir}" includes="test-1/test/*"/> | ||
</batchtest> | ||
</phpunit> | ||
<phpunit codecoverage="true"> | ||
<formatter type="xml" todir="${workspace}" outfile="test-results2.xml"/> | ||
<formatter type="clover" todir="${workspace}/2"/> | ||
<formatter type="plain" usefile="false"/> | ||
<batchtest> | ||
<fileset dir="${phing.dir}" includes="test-2/test/*"/> | ||
</batchtest> | ||
</phpunit> | ||
<phpunit codecoverage="true"> | ||
<formatter type="xml" todir="${workspace}" outfile="test-results3.xml"/> | ||
<formatter type="clover" todir="${workspace}/3"/> | ||
<formatter type="plain" usefile="false"/> | ||
<batchtest> | ||
<fileset dir="${phing.dir}" includes="test-3/test/*"/> | ||
</batchtest> | ||
</phpunit> | ||
<coverage-report outfile="${output}"/> | ||
</target> | ||
<target name="main"> | ||
<echo msg="Use this test inside the phing test suite."/> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class Dummy1 | ||
{ | ||
/** @var mixed */ | ||
private $arg; | ||
|
||
public function __construct($arg) | ||
{ | ||
$this->arg = $arg; | ||
} | ||
|
||
public function result() | ||
{ | ||
return $this->arg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
include __DIR__ . '/../src/Dummy1.php'; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class Dummy1Test extends TestCase | ||
{ | ||
public function testDummy1() | ||
{ | ||
$this->assertSame('foo', (new Dummy1('foo'))->result()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class Dummy2 | ||
{ | ||
/** @var mixed */ | ||
private $arg; | ||
|
||
public function __construct($arg) | ||
{ | ||
$this->arg = $arg; | ||
} | ||
|
||
public function result() | ||
{ | ||
return $this->arg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
include __DIR__ . '/../src/Dummy2.php'; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class Dummy2Test extends TestCase | ||
{ | ||
public function testDummy1() | ||
{ | ||
$this->assertSame('foo', (new Dummy1('foo'))->result()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
class Dummy3 | ||
{ | ||
/** @var mixed */ | ||
private $arg; | ||
|
||
public function __construct($arg) | ||
{ | ||
$this->arg = $arg; | ||
} | ||
|
||
public function result() | ||
{ | ||
return $this->arg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
include __DIR__ . '/../src/Dummy3.php'; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class Dummy3Test extends TestCase | ||
{ | ||
public function testDummy3() | ||
{ | ||
$this->assertSame('foo', (new Dummy1('foo'))->result()); | ||
} | ||
} |