[2.3] Cherry-pick @group time-sensitive annotations
This commit is contained in:
parent
f14aa486d9
commit
c9f92baad7
@ -1,41 +0,0 @@
|
||||
<?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\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'];
|
||||
}
|
@ -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();
|
||||
|
@ -1,88 +0,0 @@
|
||||
<?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\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);
|
||||
}
|
||||
}
|
@ -18,8 +18,10 @@ use Symfony\Component\HttpFoundation\Cookie;
|
||||
*
|
||||
* @author John Kary <john@johnkary.net>
|
||||
* @author Hugo Hamon <hugo.hamon@sensio.com>
|
||||
*
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class CookieTest extends ClockMockTestCase
|
||||
class CookieTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function invalidNames()
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 <markus.bachmann@bachi.biz>
|
||||
* @requires extension mongo
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class MongoDbSessionHandlerTest extends ClockMockTestCase
|
||||
class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,60 +0,0 @@
|
||||
<?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 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);
|
||||
}
|
@ -13,27 +13,17 @@ namespace Symfony\Component\Stopwatch\Tests;
|
||||
|
||||
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||
|
||||
require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
/**
|
||||
* StopwatchEventTest.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @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);
|
||||
|
@ -13,27 +13,17 @@ namespace Symfony\Component\Stopwatch\Tests;
|
||||
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
|
||||
require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
/**
|
||||
* StopwatchTest.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @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();
|
||||
|
Reference in New Issue
Block a user