Merge branch '2.3' into 2.7

* 2.3:
  [travis] Load memcache.so
  [2.3] Cherry-pick @group time-sensitive annotations
  [ci] load php_memcache.dll and apcu.so

Conflicts:
	.travis.yml
	src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php
This commit is contained in:
Nicolas Grekas 2015-10-12 14:42:24 +02:00
commit c6da10674a
17 changed files with 32 additions and 255 deletions

View File

@ -32,8 +32,9 @@ before_install:
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then phpenv config-rm xdebug.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo -e "extension = apc.so\napc.enable_cli = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.7 && echo "apc.enable_cli = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without apcu extension"; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then pecl install -f memcached-2.1.0 || echo "Let's continue without memcached extension"; fi;
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]] && [ "$deps" = "no" ]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo "extension = $(pwd)/modules/symfony_debug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini); fi;
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi;
- if [ "$deps" != "skip" ]; then ./phpunit install; fi;

View File

@ -40,6 +40,7 @@ install:
- IF %PHP%==1 copy /Y php.ini-min php.ini-max
- IF %PHP%==1 echo extension=php_apcu.dll >> php.ini-max
- IF %PHP%==1 echo apc.enable_cli=1 >> php.ini-max
- IF %PHP%==1 echo extension=php_memcache.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_intl.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini-max

View File

@ -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'];
}

View File

@ -13,25 +13,13 @@ 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 legacy
* @group time-sensitive
*/
class LegacyProgressHelperTest 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();

View File

@ -14,22 +14,12 @@ namespace Symfony\Component\Console\Tests\Helper;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Tests;
require_once __DIR__.'/../ClockMock.php';
/**
* @group time-sensitive
*/
class ProgressBarTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
Tests\with_clock_mock(true);
}
protected function tearDown()
{
Tests\with_clock_mock(false);
}
public function testMultipleStart()
{
$bar = new ProgressBar($output = $this->getOutputStream());

View File

@ -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);
}
}

View File

@ -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()
{

View File

@ -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

View File

@ -12,13 +12,13 @@
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler;
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
/**
* @group legacy
* @group time-sensitive
* @requires extension pdo_sqlite
*/
class LegacyPdoSessionHandlerTest extends ClockMockTestCase
class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
{
private $pdo;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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 $dbFile;

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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();