minor #15166 Mock microtime() and time() in transient tests (nicolas-grekas)
This PR was merged into the 2.3 branch.
Discussion
----------
Mock microtime() and time() in transient tests
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Commits
-------
8319ca3
Mock microtime() and time() in transient tests
This commit is contained in:
commit
6bcdee057e
|
@ -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