8000 Added test for the CoverageListener · symfony/symfony@110d57c · GitHub
[go: up one dir, main page]

Skip to content

Commit 110d57c

Browse files
committed
Added test for the CoverageListener
1 parent ac1bfe6 commit 110d57c

File tree

8 files changed

+165
-1
lines changed

8 files changed

+165
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ install:
196196
elif [[ $PHP = hhvm* ]]; then
197197
$PHPUNIT --exclude-group benchmark,intl-data
198198
else
199-
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
199+
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}/Tests"
200200
tfold tty-group $PHPUNIT --group tty
201201
if [[ $PHP = ${MIN_PHP%.*} ]]; then
202202
echo -e "1\\n0" | xargs -I{} bash -c "tfold src/Symfony/Component/Process.sigchild{} SYMFONY_DEPRECATIONS_HELPER=weak ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="tests/bootstrap.php"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
>
11+
12+
<testsuites>
13+
<testsuite name="Fixtures/coverage Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<filter>
19+
<whitelist>
20+
<directory>src</directory>
21+
</whitelist>
22+
</filter>
23+
24+
<listeners>
25+
<listener class="Symfony\Bridge\PhpUnit\CoverageListener" />
26+
</listeners>
27+
</phpunit>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="tests/bootstrap.php"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
>
11+
12+
<testsuites>
13+
<testsuite name="Fixtures/coverage Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
18+
<filter>
19+
<whitelist>
20+
<directory>src</directory>
21+
</whitelist>
22+
</filter>
23+
</phpunit>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
class Bar
13+
{
14+
private $foo;
15+
16+
public function __construct(Foo $foo)
17+
{
18+
$this->foo = $foo;
19+
}
20+
21+
public function barZ()
22+
{
23+
$this->foo->fooZ();
24+
25+
return 'bar';
26+
}
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
class Foo
13+
{
14+
public function fooZ()
15+
{
16+
return 'foo';
17+
}
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
class BarTest extends TestCase
15+
{
16+
public function testBar()
17+
{
18+
$foo = new Foo();
19+
$bar = new Bar($foo);
20+
21+
$this->assertSame('bar', $bar->barZ());
22+
}
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
require __DIR__.'/../src/Bar.php';
13+
require __DIR__.'/../src/Foo.php';
14+
15+
require __DIR__.'/../../../Legacy/CoverageListenerTrait.php';
16+
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
17+
require __DIR__.'/../../../Legacy/CoverageListener.php';
18+
}
19+
require __DIR__.'/../../../CoverageListener.php';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line number D6B2 Diff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\PhpUnit\Tests;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
class CoverageListenerTest extends TestCase
8+
{
9+
public function test()
10+
{
11+
if ("\n" !== PHP_EOL) {
12+
$this->markTestSkipped('This test cannot be run on Windows.');
13+
}
14+
15+
$dir = __DIR__.'/../Tests-Fixtures/coverage';
16+
$php = PHP_BINARY;
17+
$phpunit = $_SERVER['argv'][0];
18+
19+
exec("$php -d zend_extension=xdebug.so $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text", $output);
20+
$output = implode("\n", $output);
21+
$this->assertNotContains('Foo', $output);
22+
23+
exec("$php -d zend_extension=xdebug.so $phpunit -c $dir/phpunit-without-listener.xml.dist $dir/tests/ --coverage-text", $output);
24+
$output = implode("\n", $output);
25+
$this->assertContains('Foo', $output);
26+
}
27+
}

0 commit comments

Comments
 (0)
0