Skip to content

Commit 2b60058

Browse files
minor #16197 [PhpUnit] Auto-register SymfonyTestsListener (nicolas-grekas)
This PR was merged into the 2.8 branch. Discussion ---------- [PhpUnit] Auto-register SymfonyTestsListener | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This allows removing the copy/pasted `<listeners>` tags in our phpunit.xml.dist files and opens for future enhancements (like #16194) Commits ------- 9e2bb00 [PhpUnit] Auto-register SymfonyTestsListener
2 parents 45b2382 + 9e2bb00 commit 2b60058

File tree

50 files changed

+67
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+67
-185
lines changed

phpunit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
4747
passthru("$COMPOSER remove --no-update symfony/yaml");
4848
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\"");
4949
passthru("$COMPOSER install --prefer-source --no-progress --ansi");
50+
file_put_contents('phpunit', <<<EOPHP
51+
<?php
52+
53+
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
54+
require PHPUNIT_COMPOSER_INSTALL;
55+
Symfony\Bridge\PhpUnit\TextUI\Command::main();
56+
57+
EOPHP
58+
);
5059
chdir('..');
5160
if (file_exists('../src/Symfony/Bridge/PhpUnit') && `git diff --name-only HEAD^ -- ../src/Symfony/Bridge/PhpUnit`) {
5261
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'del /S /F /Q %s & rmdir %1$s >nul 2>&1': 'rm -rf %s', str_replace('/', DIRECTORY_SEPARATOR, "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge")));

phpunit.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,4 @@
4343
</exclude>
4444
</whitelist>
4545
</filter>
46-
47-
<listeners>
48-
<listener class="Symfony\Bridge\PhpUnit\SkippedTestsListener" />
49-
</listeners>
5046
</phpunit>

src/Symfony/Bridge/Doctrine/phpunit.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@
2525
</exclude>
2626
</whitelist>
2727
</filter>
28-
29-
<listeners>
30-
<listener class="Symfony\Bridge\PhpUnit\SkippedTestsListener" />
31-
</listeners>
3228
</phpunit>

src/Symfony/Bridge/Monolog/phpunit.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@
2525
</exclude>
2626
</whitelist>
2727
</filter>
28-
29-
<listeners>
30-
<listener class="Symfony\Bridge\PhpUnit\SkippedTestsListener" />
31-
</listeners>
3228
</phpunit>

src/Symfony/Bridge/PhpUnit/SkippedTestsListener.php renamed to src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @author Nicolas Grekas <p@tchwork.com>
2020
*/
21-
class SkippedTestsListener extends \PHPUnit_Framework_BaseTestListener
21+
class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
2222
{
2323
private $state = -1;
2424
private $skippedFile = false;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
namespace Symfony\Bridge\PhpUnit\TextUI;
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
class Command extends \PHPUnit_TextUI_Command
18+
{
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
protected function createRunner()
23+
{
24+
return new TestRunner($this->arguments['loader']);
25+
}
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
namespace Symfony\Bridge\PhpUnit\TextUI;
13+
14+
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
15+
16+
/**
17+
* {@inheritdoc}
18+
*/
19+
class TestRunner extends \PHPUnit_TextUI_TestRunner
20+
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
protected function handleConfiguration(array &$arguments)
25+
{
26+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
27+
$arguments['listeners'][] = new SymfonyTestsListener();
28+
29+
return parent::handleConfiguration($arguments);
30+
}
31+
}

src/Symfony/Bridge/ProxyManager/phpunit.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@
2626
</exclude>
2727
</whitelist>
2828
</filter>
29-
30-
<listeners>
31-
<listener class="Symfony\Bridge\PhpUnit\SkippedTestsListener" />
32-
</listeners>
3329
</phpunit>

src/Symfony/Bridge/Twig/phpunit.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@
2626
</exclude>
2727
</whitelist>
2828
</filter>
29-
30-
<listeners>
31-
<listener class="Symfony\Bridge\PhpUnit\SkippedTestsListener" />
32-
</listeners>
3329
</phpunit>

src/Symfony/Bundle/DebugBundle/phpunit.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@
2626
</exclude>
2727
</whitelist>
2828
</filter>
29-
30-
<listeners>
31-
<listener class="Symfony\Bridge\PhpUnit\SkippedTestsListener" />
32-
</listeners>
3329
</phpunit>

0 commit comments

Comments
 (0)