minor #15848 [Console] Add clock mock to fix transient test on HHVM (nicolas-grekas)
This PR was merged into the 2.3 branch.
Discussion
----------
[Console] Add clock mock to fix transient test on HHVM
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
This should fix the most frequent transient test on HHVM (ProgressBarTest::testAnsiColorsAndEmojis)
Commits
-------
549f43b
[Console] Add clock mock to fix transient test on HHVM
This commit is contained in:
commit
451bdc0bf0
41
src/Symfony/Component/Console/Tests/ClockMock.php
Normal file
41
src/Symfony/Component/Console/Tests/ClockMock.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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,9 +13,22 @@ namespace Symfony\Component\Console\Tests\Helper;
|
|||||||
|
|
||||||
use Symfony\Component\Console\Helper\ProgressHelper;
|
use Symfony\Component\Console\Helper\ProgressHelper;
|
||||||
use Symfony\Component\Console\Output\StreamOutput;
|
use Symfony\Component\Console\Output\StreamOutput;
|
||||||
|
use Symfony\Component\Console\Tests;
|
||||||
|
|
||||||
|
require_once __DIR__.'/../ClockMock.php';
|
||||||
|
|
||||||
class ProgressHelperTest extends \PHPUnit_Framework_TestCase
|
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()
|
public function testAdvance()
|
||||||
{
|
{
|
||||||
$progress = new ProgressHelper();
|
$progress = new ProgressHelper();
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpFoundation;
|
namespace Symfony\Component\HttpFoundation;
|
||||||
|
|
||||||
function time($asFloat = false)
|
function time()
|
||||||
{
|
{
|
||||||
return Tests\time();
|
return Tests\time();
|
||||||
}
|
}
|
||||||
|
@ -23,16 +23,14 @@ require_once __DIR__.'/ClockMock.php';
|
|||||||
*/
|
*/
|
||||||
class CookieTest extends \PHPUnit_Framework_TestCase
|
class CookieTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
with_clock_mock(true);
|
with_clock_mock(true);
|
||||||
parent::setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
with_clock_mock(false);
|
with_clock_mock(false);
|
||||||
parent::tearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidNames()
|
public function invalidNames()
|
||||||
|
@ -18,16 +18,14 @@ require_once __DIR__.'/ClockMock.php';
|
|||||||
|
|
||||||
class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
|
class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
with_clock_mock(true);
|
with_clock_mock(true);
|
||||||
parent::setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
with_clock_mock(false);
|
with_clock_mock(false);
|
||||||
parent::tearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,16 +24,14 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
const DELTA = 37;
|
const DELTA = 37;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
with_clock_mock(true);
|
with_clock_mock(true);
|
||||||
parent::setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
with_clock_mock(false);
|
with_clock_mock(false);
|
||||||
parent::tearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetOrigin()
|
public function testGetOrigin()
|
||||||
|
@ -24,16 +24,14 @@ class StopwatchTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
const DELTA = 20;
|
const DELTA = 20;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
with_clock_mock(true);
|
with_clock_mock(true);
|
||||||
parent::setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
with_clock_mock(false);
|
with_clock_mock(false);
|
||||||
parent::tearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStart()
|
public function testStart()
|
||||||
|
Reference in New Issue
Block a user