diff --git a/src/Symfony/Component/Console/Tests/ClockMock.php b/src/Symfony/Component/Console/Tests/ClockMock.php deleted file mode 100644 index 0e9231662e..0000000000 --- a/src/Symfony/Component/Console/Tests/ClockMock.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Tests; - -function time() -{ - return Tests\time(); -} - -namespace Symfony\Component\Console\Tests; - -function with_clock_mock($enable = null) -{ - static $enabled; - - if (null === $enable) { - return $enabled; - } - - $enabled = $enable; -} - -function time() -{ - if (!with_clock_mock()) { - return \time(); - } - - return $_SERVER['REQUEST_TIME']; -} diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php index 0afcf044e5..5043b493c9 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php @@ -13,22 +13,12 @@ namespace Symfony\Component\Console\Tests\Helper; use Symfony\Component\Console\Helper\ProgressHelper; use Symfony\Component\Console\Output\StreamOutput; -use Symfony\Component\Console\Tests; - -require_once __DIR__.'/../ClockMock.php'; +/** + * @group time-sensitive + */ class ProgressHelperTest extends \PHPUnit_Framework_TestCase { - protected function setUp() - { - Tests\with_clock_mock(true); - } - - protected function tearDown() - { - Tests\with_clock_mock(false); - } - public function testAdvance() { $progress = new ProgressHelper(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ClockMockTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/ClockMockTestCase.php deleted file mode 100644 index ba009168f3..0000000000 --- a/src/Symfony/Component/HttpFoundation/Tests/ClockMockTestCase.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\HttpFoundationSession\Tests\Storage\Handler; - -use Symfony\Component\HttpFoundation\Tests; - -function time() -{ - return Tests\time(); -} - -namespace Symfony\Component\HttpFoundationSession\Storage\Handler; - -use Symfony\Component\HttpFoundation\Tests; - -function time() -{ - return Tests\time(); -} - -namespace Symfony\Component\HttpFoundationSession\Tests\Storage; - -use Symfony\Component\HttpFoundation\Tests; - -function time() -{ - return Tests\time(); -} - -namespace Symfony\Component\HttpFoundationSession\Storage; - -use Symfony\Component\HttpFoundation\Tests; - -function time() -{ - return Tests\time(); -} - -namespace Symfony\Component\HttpFoundation; - -function time() -{ - return Tests\time(); -} - -namespace Symfony\Component\HttpFoundation\Tests; - -function with_clock_mock($enable = null) -{ - static $enabled; - - if (null === $enable) { - return $enabled; - } - - $enabled = $enable; -} - -function time() -{ - if (!with_clock_mock()) { - return \time(); - } - - return $_SERVER['REQUEST_TIME']; -} - -class ClockMockTestCase extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - with_clock_mock(true); - } - - protected function tearDown() - { - with_clock_mock(false); - } -} diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 831eef0c65..5b9438911d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -18,8 +18,10 @@ use Symfony\Component\HttpFoundation\Cookie; * * @author John Kary * @author Hugo Hamon + * + * @group time-sensitive */ -class CookieTest extends ClockMockTestCase +class CookieTest extends \PHPUnit_Framework_TestCase { public function invalidNames() { diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 48e049f87b..b716ac162a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -14,7 +14,10 @@ namespace Symfony\Component\HttpFoundation\Tests; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpFoundation\Cookie; -class ResponseHeaderBagTest extends ClockMockTestCase +/** + * @group time-sensitive + */ +class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase { /** * @covers Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index 3c5144d68e..81b4075992 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -12,12 +12,12 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler; -use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase; /** * @requires extension memcache + * @group time-sensitive */ -class MemcacheSessionHandlerTest extends ClockMockTestCase +class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase { const PREFIX = 'prefix_'; const TTL = 1000; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index d29ab4b00b..34276ce8ee 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -12,12 +12,12 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler; -use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase; /** * @requires extension memcached + * @group time-sensitive */ -class MemcachedSessionHandlerTest extends ClockMockTestCase +class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase { const PREFIX = 'prefix_'; const TTL = 1000; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 7634fea49c..c72358afc8 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -12,13 +12,13 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; -use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase; /** * @author Markus Bachmann * @requires extension mongo + * @group time-sensitive */ -class MongoDbSessionHandlerTest extends ClockMockTestCase +class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 19de8ac731..1936b1c294 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -12,12 +12,12 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; -use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase; /** * @requires extension pdo_sqlite + * @group time-sensitive */ -class PdoSessionHandlerTest extends ClockMockTestCase +class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase { private $pdo; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php index b7f4b3c8b4..b1453e4540 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php @@ -12,12 +12,13 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; -use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase; /** * Test class for MetadataBag. + * + * @group time-sensitive */ -class MetadataBagTest extends ClockMockTestCase +class MetadataBagTest extends \PHPUnit_Framework_TestCase { /** * @var MetadataBag diff --git a/src/Symfony/Component/Stopwatch/Tests/ClockMock.php b/src/Symfony/Component/Stopwatch/Tests/ClockMock.php deleted file mode 100644 index 718296cc5b..0000000000 --- a/src/Symfony/Component/Stopwatch/Tests/ClockMock.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Stopwatch; - -function microtime($asFloat = false) -{ - return Tests\microtime($asFloat); -} - -namespace Symfony\Component\Stopwatch\Tests; - -function with_clock_mock($enable = null) -{ - static $enabled; - - if (null === $enable) { - return $enabled; - } - - $enabled = $enable; -} - -function usleep($us) -{ - static $now; - - if (!with_clock_mock()) { - \usleep($us); - - return; - } - - if (null === $now) { - $now = \microtime(true); - } - - return $now += $us / 1000000; -} - -function microtime($asFloat = false) -{ - if (!with_clock_mock()) { - return \microtime($asFloat); - } - - if (!$asFloat) { - return \microtime(false); - } - - return usleep(1); -} diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index f67d9dc16d..79db149f91 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -13,27 +13,17 @@ namespace Symfony\Component\Stopwatch\Tests; use Symfony\Component\Stopwatch\StopwatchEvent; -require_once __DIR__.'/ClockMock.php'; - /** * StopwatchEventTest. * * @author Fabien Potencier + * + * @group time-sensitive */ class StopwatchEventTest extends \PHPUnit_Framework_TestCase { const DELTA = 37; - protected function setUp() - { - with_clock_mock(true); - } - - protected function tearDown() - { - with_clock_mock(false); - } - public function testGetOrigin() { $event = new StopwatchEvent(12); diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index b7835c6a02..1994fe06ff 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -13,27 +13,17 @@ namespace Symfony\Component\Stopwatch\Tests; use Symfony\Component\Stopwatch\Stopwatch; -require_once __DIR__.'/ClockMock.php'; - /** * StopwatchTest. * * @author Fabien Potencier + * + * @group time-sensitive */ class StopwatchTest extends \PHPUnit_Framework_TestCase { const DELTA = 20; - protected function setUp() - { - with_clock_mock(true); - } - - protected function tearDown() - { - with_clock_mock(false); - } - public function testStart() { $stopwatch = new Stopwatch();