diff --git a/src/Symfony/Component/HttpFoundation/Tests/ClockMock.php b/src/Symfony/Component/HttpFoundation/Tests/ClockMock.php new file mode 100644 index 0000000000..04a842d9b5 --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Tests/ClockMock.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation; + +function time($asFloat = false) +{ + return Tests\time(); +} + +namespace Symfony\Component\HttpFoundation\Tests; + +function time() +{ + return $_SERVER['REQUEST_TIME']; +} diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 0aaeb6baa1..b8474db15f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -13,6 +13,8 @@ namespace Symfony\Component\HttpFoundation\Tests; use Symfony\Component\HttpFoundation\Cookie; +require_once __DIR__.'/ClockMock.php'; + /** * CookieTest. * diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 8ff8662e99..b4164c8a28 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -14,6 +14,8 @@ namespace Symfony\Component\HttpFoundation\Tests; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpFoundation\Cookie; +require_once __DIR__.'/ClockMock.php'; + class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase { /** diff --git a/src/Symfony/Component/Stopwatch/Tests/ClockMock.php b/src/Symfony/Component/Stopwatch/Tests/ClockMock.php new file mode 100644 index 0000000000..5bbe6b1db8 --- /dev/null +++ b/src/Symfony/Component/Stopwatch/Tests/ClockMock.php @@ -0,0 +1,39 @@ + + * + * 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 usleep($us) +{ + static $now; + + if (null === $now) { + $now = \microtime(true); + } + + return $now += $us / 1000000; +} + +function microtime($asFloat = false) +{ + 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 9ef3abaea9..44928ace19 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -13,6 +13,8 @@ namespace Symfony\Component\Stopwatch\Tests; use Symfony\Component\Stopwatch\StopwatchEvent; +require_once __DIR__.'/ClockMock.php'; + /** * StopwatchEventTest. * diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 74ad1d8da1..f13955d30b 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -13,6 +13,8 @@ namespace Symfony\Component\Stopwatch\Tests; use Symfony\Component\Stopwatch\Stopwatch; +require_once __DIR__.'/ClockMock.php'; + /** * StopwatchTest. *