diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index ed5c1125e5..e0427e6ae8 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -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')); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/ClockMock.php b/src/Symfony/Component/HttpFoundation/Tests/ClockMock.php deleted file mode 100644 index aa954db429..0000000000 --- a/src/Symfony/Component/HttpFoundation/Tests/ClockMock.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * 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']; -} diff --git a/src/Symfony/Component/HttpFoundation/Tests/ClockMockTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/ClockMockTestCase.php new file mode 100644 index 0000000000..ba009168f3 --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Tests/ClockMockTestCase.php @@ -0,0 +1,88 @@ + + * + * 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); + } +} diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 378e1c5c57..831eef0c65 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -13,26 +13,14 @@ namespace Symfony\Component\HttpFoundation\Tests; use Symfony\Component\HttpFoundation\Cookie; -require_once __DIR__.'/ClockMock.php'; - /** * CookieTest. * * @author John Kary * @author Hugo Hamon */ -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( diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 09aac42e58..704b65ef4c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -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 diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php index cfc9cfc85f..4cedab0db9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php @@ -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)'; diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index 33fb3f933e..3c55681dea 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -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() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index e138b7169b..5fba84dde0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -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() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index a59c6635f4..5807c62834 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -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 * @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) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 641362af3b..8393e68c2d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -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() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php index fb632a84f5..8767410939 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php @@ -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() diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index adb9901262..b2f60f9ffd 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -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); } diff --git a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php index 98eeb0ecbc..b3ee5c00f8 100644 --- a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -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(); } diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 1c42e76362..0ae752166a 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -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',