Merge branch '2.7' into 2.8
* 2.7: [Filesystem] Fix test on Windows Fix merge [HttpFoundation] Extend ClockMock to session storage tests [Process] Don't use @requires on abstract class [VarDumper] Fix wordwrap with Bootstrap
This commit is contained in:
commit
dac3c9e82d
@ -915,7 +915,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertTrue(is_dir($targetPath));
|
||||
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
|
||||
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||
$this->assertEquals('nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||
$this->assertEquals('\\' === DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,39 +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\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'];
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
@ -13,26 +13,14 @@ namespace Symfony\Component\HttpFoundation\Tests;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
require_once __DIR__.'/ClockMock.php';
|
||||
|
||||
/**
|
||||
* CookieTest.
|
||||
*
|
||||
* @author John Kary <john@johnkary.net>
|
||||
* @author Hugo Hamon <hugo.hamon@sensio.com>
|
||||
*/
|
||||
class CookieTest extends \PHPUnit_Framework_TestCase
|
||||
class CookieTest extends ClockMockTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
with_clock_mock(true);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
with_clock_mock(false);
|
||||
}
|
||||
|
||||
public function invalidNames()
|
||||
{
|
||||
return array(
|
||||
|
@ -14,20 +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
|
||||
class ResponseHeaderBagTest extends ClockMockTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
with_clock_mock(true);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
with_clock_mock(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase
|
||||
* @dataProvider provideAllPreserveCase
|
||||
|
@ -12,17 +12,19 @@
|
||||
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler;
|
||||
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @requires extension pdo_sqlite
|
||||
*/
|
||||
class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
class LegacyPdoSessionHandlerTest extends ClockMockTestCase
|
||||
{
|
||||
private $pdo;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->pdo = new \PDO('sqlite::memory:');
|
||||
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$sql = 'CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)';
|
||||
|
@ -12,11 +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
|
||||
*/
|
||||
class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
class MemcacheSessionHandlerTest extends ClockMockTestCase
|
||||
{
|
||||
const PREFIX = 'prefix_';
|
||||
const TTL = 1000;
|
||||
@ -29,6 +30,7 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->memcache = $this->getMock('Memcache');
|
||||
$this->storage = new MemcacheSessionHandler(
|
||||
$this->memcache,
|
||||
@ -40,6 +42,7 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->memcache = null;
|
||||
$this->storage = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testOpenSession()
|
||||
|
@ -12,11 +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
|
||||
*/
|
||||
class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
class MemcachedSessionHandlerTest extends ClockMockTestCase
|
||||
{
|
||||
const PREFIX = 'prefix_';
|
||||
const TTL = 1000;
|
||||
@ -30,6 +31,8 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (version_compare(phpversion('memcached'), '2.2.0', '>=')) {
|
||||
$this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower');
|
||||
}
|
||||
@ -45,6 +48,7 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->memcached = null;
|
||||
$this->storage = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testOpenSession()
|
||||
|
@ -12,12 +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
|
||||
*/
|
||||
class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
class MongoDbSessionHandlerTest extends ClockMockTestCase
|
||||
{
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
@ -28,6 +29,8 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient';
|
||||
|
||||
$this->mongo = $this->getMockBuilder($mongoClass)
|
||||
|
@ -12,11 +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
|
||||
*/
|
||||
class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
class PdoSessionHandlerTest extends ClockMockTestCase
|
||||
{
|
||||
private $dbFile;
|
||||
|
||||
@ -26,6 +27,7 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
if ($this->dbFile) {
|
||||
@unlink($this->dbFile);
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function getPersistentSqliteDsn()
|
||||
|
@ -12,11 +12,12 @@
|
||||
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag;
|
||||
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
|
||||
|
||||
/**
|
||||
* Test class for MetadataBag.
|
||||
*/
|
||||
class MetadataBagTest extends \PHPUnit_Framework_TestCase
|
||||
class MetadataBagTest extends ClockMockTestCase
|
||||
{
|
||||
/**
|
||||
* @var MetadataBag
|
||||
@ -30,6 +31,7 @@ class MetadataBagTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->bag = new MetadataBag();
|
||||
$this->array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0);
|
||||
$this->bag->initialize($this->array);
|
||||
@ -39,6 +41,7 @@ class MetadataBagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->array = array();
|
||||
$this->bag = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testInitialize()
|
||||
|
@ -72,11 +72,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($p->getTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension pcntl
|
||||
*/
|
||||
public function testStopWithTimeoutIsActuallyWorking()
|
||||
{
|
||||
if (!extension_loaded('pcntl')) {
|
||||
$this->markTestSkipped('Extension pcntl is required.');
|
||||
}
|
||||
|
||||
// exec is mandatory here since we send a signal to the process
|
||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||
// command with exec
|
||||
@ -721,11 +722,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($termSignal, $process->getTermSignal());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires function posix_kill
|
||||
*/
|
||||
public function testProcessThrowsExceptionWhenExternallySignaled()
|
||||
{
|
||||
if (!function_exists('posix_kill')) {
|
||||
$this->markTestSkipped('Function posix_kill is required.');
|
||||
}
|
||||
|
||||
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
|
||||
|
||||
$process = $this->getProcess('exec php -r "while (true) {}"');
|
||||
@ -898,11 +900,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension pcntl
|
||||
*/
|
||||
public function testSignal()
|
||||
{
|
||||
if (!extension_loaded('pcntl')) {
|
||||
$this->markTestSkipped('Extension pcntl is required.');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('exec php -f '.__DIR__.'/SignalListener.php');
|
||||
$process->start();
|
||||
usleep(500000);
|
||||
@ -915,11 +918,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('Caught SIGUSR1', $process->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires extension pcntl
|
||||
*/
|
||||
public function testExitCodeIsAvailableAfterSignal()
|
||||
{
|
||||
if (!extension_loaded('pcntl')) {
|
||||
$this->markTestSkipped('Extension pcntl is required.');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('sleep 4');
|
||||
$process->start();
|
||||
$process->signal(SIGKILL);
|
||||
@ -936,10 +940,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||
* @requires extension pcntl
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
if (!extension_loaded('pcntl')) {
|
||||
$this->markTestSkipped('Extension pcntl is required.');
|
||||
}
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process->signal(SIGHUP);
|
||||
}
|
||||
|
@ -121,9 +121,12 @@ class SimpleProcessTest extends AbstractProcessTest
|
||||
parent::testExitCodeIsAvailableAfterSignal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||
* @expectedExceptionMessage Can not send signal on a non running process.
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', 'Can not send signal on a non running process.');
|
||||
parent::testSignalProcessNotRunning();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class HtmlDumper extends CliDumper
|
||||
protected $headerIsDumped = false;
|
||||
protected $lastDepth = -1;
|
||||
protected $styles = array(
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000; word-break: normal',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'str' => 'font-weight:bold; color:#56DB3A',
|
||||
|
Reference in New Issue
Block a user