diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
index 4dd52d4e7705..4f4dc78508c2 100644
--- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
+++ b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
@@ -20,11 +20,26 @@
*/
class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
{
+ private static $globallyEnabled = false;
private $state = -1;
private $skippedFile = false;
private $wasSkipped = array();
private $isSkipped = array();
+ public function __construct(array $extraClockMockedNamespaces = array())
+ {
+ if ($extraClockMockedNamespaces) {
+ foreach ($extraClockMockedNamespaces as $ns) {
+ ClockMock::register($ns.'\DummyClass');
+ }
+ }
+ if (self::$globallyEnabled) {
+ $this->state = -2;
+ } else {
+ self::$globallyEnabled = true;
+ }
+ }
+
public function __destruct()
{
if (0 < $this->state) {
@@ -56,9 +71,16 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
}
}
}
- foreach ($suite->tests() as $test) {
- if ($test instanceof \PHPUnit_Framework_TestSuite && in_array('time-sensitive', \PHPUnit_Util_Test::getGroups($test->getName()), true)) {
- ClockMock::register($test->getName());
+ $testSuites = array($suite);
+ for ($i = 0; isset($testSuites[$i]); ++$i) {
+ foreach ($testSuites[$i]->tests() as $test) {
+ if ($test instanceof \PHPUnit_Framework_TestSuite) {
+ if (class_exists($test->getName(), false) && in_array('time-sensitive', \PHPUnit_Util_Test::getGroups($test->getName()), true)) {
+ ClockMock::register($test->getName());
+ } else {
+ $testSuites[] = $test;
+ }
+ }
}
}
} elseif (2 === $this->state) {
@@ -91,7 +113,7 @@ public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $ti
public function startTest(\PHPUnit_Framework_Test $test)
{
- if ($test instanceof \PHPUnit_Framework_TestCase) {
+ if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName());
if (in_array('time-sensitive', $groups, true)) {
@@ -103,7 +125,7 @@ public function startTest(\PHPUnit_Framework_Test $test)
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
- if ($test instanceof \PHPUnit_Framework_TestCase) {
+ if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
$groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName());
if (in_array('time-sensitive', $groups, true)) {
diff --git a/src/Symfony/Component/HttpKernel/phpunit.xml.dist b/src/Symfony/Component/HttpKernel/phpunit.xml.dist
index 13149663e488..17c48935c715 100644
--- a/src/Symfony/Component/HttpKernel/phpunit.xml.dist
+++ b/src/Symfony/Component/HttpKernel/phpunit.xml.dist
@@ -25,4 +25,14 @@
+
+
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: