Mock microtime() and time() in transient tests
This commit is contained in:
parent
9de0d60b2c
commit
8319ca3b05
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* 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'];
|
||||
}
|
|
@ -13,6 +13,8 @@ namespace Symfony\Component\HttpFoundation\Tests;
|
|||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
/**
|
||||
* CookieTest.
|
||||
*
|
||||
|
|
|
@ -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
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* 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);
|
||||
}
|
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Stopwatch\Tests;
|
|||
|
||||
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||
|
||||
require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
/**
|
||||
* StopwatchEventTest.
|
||||
*
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace Symfony\Component\Stopwatch\Tests;
|
|||
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
|
||||
require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
/**
|
||||
* StopwatchTest.
|
||||
*
|
||||
|
|
Reference in New Issue