8000 Merge branch '2.3' into 2.7 · symfony/symfony@f0b03bd · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit f0b03bd

Browse files
Merge branch '2.3' into 2.7
* 2.3: [HttpFoundation] Extend ClockMock to session storage tests [Process] Don't use @requires on abstract class Conflicts: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
2 parents 553ac3a + 1ee8d2b commit f0b03bd

12 files changed

+136
-85
lines changed

src/Symfony/Component/HttpFoundation/Tests/ClockMock.php

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundationSession\Tests\Storage\Handler;
13+
14+
use Symfony\Component\HttpFoundation\Tests;
15+
16+
function time()
17+
{
18+
return Tests\time();
19+
}
20+
21+
namespace Symfony\Component\HttpFoundationSession\Storage\Handler;
22+
23+
use Symfony\Component\HttpFoundation\Tests;
24+
25+
function time()
26+
{
27+
return Tests\time();
28+
}
29+
30+
namespace Symfony\Component\HttpFoundationSession\Tests\Storage;
31+
32+
use Symfony\Component\HttpFoundation\Tests;
33+
34+
function time()
35+
{
36+
return Tests\time();
37+
}
38+
39+
namespace Symfony\Component\HttpFoundationSession\Storage;
40+
41+
use Symfony\Component\HttpFoundation\Tests;
42+
43+
function time()
44+
{
45+
return Tests\time();
46+
}
47+
48+
namespace Symfony\Component\HttpFoundation;
49+
50+
function time()
51+
{
52+
return Tests\time();
53+
}
54+
55+
namespace Symfony\Component\HttpFoundation\Tests;
56+
57+
function with_clock_mock($enable = null)
58+
{
59+
static $enabled;
60+
61+
if (null === $enable) {
62+
return $enabled;
63+
}
64+
65+
$enabled = $enable;
66+
}
67+
68+
function time() 9E88
69+
{
70+
if (!with_clock_mock()) {
71+
return \time();
72+
}
73+
74+
return $_SERVER['REQUEST_TIME'];
75+
}
76+
77+
class ClockMockTestCase extends \PHPUnit_Framework_TestCase
78+
{
79+
protected function setUp()
80+
{
81+
with_clock_mock(true);
82+
}
83+
84+
protected function tearDown()
85+
{
86+
with_clock_mock(false);
87+
}
88+
}

src/Symfony/Component/HttpFoundation/Tests/CookieTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,14 @@
1313

1414
use Symfony\Component\HttpFoundation\Cookie;
1515

16-
require_once __DIR__.'/ClockMock.php';
17-
1816
/**
1917
* CookieTest.
2018
*
2119
* @author John Kary <john@johnkary.net>
2220
* @author Hugo Hamon <hugo.hamon@sensio.com>
2321
*/
24-
class CookieTest extends \PHPUnit_Framework_TestCase
22+
class CookieTest extends ClockMockTestCase
2523
{
26-
protected function setUp()
27-
{
28-
with_clock_mock(true);
29-
}
30-
31-
protected function tearDown()
32-
{
33-
with_clock_mock(false);
34-
}
35-
3624
public function invalidNames()
3725
{
3826
return array(

src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,8 @@
1414
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
1515
use Symfony\Component\HttpFoundation\Cookie;
1616

17-
require_once __DIR__.'/ClockMock.php';
18-
19-
class ResponseHeaderBagTest extends \PHPUnit_Framework_TestCase
17+
class ResponseHeaderBagTest extends ClockMockTestCase
2018
{
21-
protected function setUp()
22-
{
23-
with_clock_mock(true);
24-
}
25-
26-
protected function tearDown()
27-
{
28-
with_clock_mock(false);
29-
}
30-
3119
/**
3220
* @covers Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCase
3321
* @dataProvider provideAllPreserveCase

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/LegacyPdoSessionHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
* @group legacy
1818
* @requires extension pdo_sqlite
1919
*/
20-
class LegacyPdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
20+
class LegacyPdoSessionHandlerTest extends ClockMockTestCase
2121
{
2222
private $pdo;
2323

2424
protected function setUp()
2525
{
26+
parent::setUp();
2627
$this->pdo = new \PDO('sqlite::memory:');
2728
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
2829
$sql = 'CREATE TABLE sessions (sess_id VARCHAR(128) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)';

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
1313

1414
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler;
15+
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
1516

1617
/**
1718
* @requires extension memcache
1819
*/
19-
class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
20+
class MemcacheSessionHandlerTest extends ClockMockTestCase
2021
{
2122
const PREFIX = 'prefix_';
2223
const TTL = 1000;
@@ -29,6 +30,7 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase
2930

3031
protected function setUp()
3132
{
33+
parent::setUp();
3234
$this->memcache = $this->getMock('Memcache');
3335
$this->storage = new MemcacheSessionHandler(
3436
$this->memcache,
@@ -40,6 +42,7 @@ protected function tearDown()
4042
{
4143
$this->memcache = null;
4244
$this->storage = null;
45+
parent::tearDown();
4346
}
4447

4548
public function testOpenSession()

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
1313

1414
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
15+
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
1516

1617
/**
1718
* @requires extension memcached
1819
*/
19-
class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
20+
class MemcachedSessionHandlerTest extends ClockMockTestCase
2021
{
2122
const PREFIX = 'prefix_';
2223
const TTL = 1000;
@@ -30,6 +31,8 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase
3031

3132
protected function setUp()
3233
{
34+
parent::setUp();
35+
3336
if (version_compare(phpversion('memcached'), '2.2.0', '>=')) {
3437
$this->markTestSkipped('Tests can only be run with memcached extension 2.1.0 or lower');
3538
}
@@ -45,6 +48,7 @@ protected function tearDown()
4548
{
4649
$this->memcached = null;
4750
$this->storage = null;
51+
parent::tearDown();
4852
}
4953

5054
public function testOpenSession()

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
1313

1414
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler;
15+
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
1516

1617
/**
1718
* @author Markus Bachmann <markus.bachmann@bachi.biz>
1819
* @requires extension mongo
1920
*/
20-
class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
21+
class MongoDbSessionHandlerTest extends ClockMockTestCase
2122
{
2223
/**
2324
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -28,6 +29,8 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
2829

2930
protected function setUp()
3031
{
32+
parent::setUp();
33+
3134
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient';
3235

3336
$this->mongo = $this->getMockBuilder($mongoClass)

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
1313

1414
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
15+
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
1516

1617
/**
1718
* @requires extension pdo_sqlite
1819
*/
19-
class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase
20+
class PdoSessionHandlerTest extends ClockMockTestCase
2021
{
2122
private $dbFile;
2223

@@ -26,6 +27,7 @@ protected function tearDown()
2627
if ($this->dbFile) {
2728
@unlink($this->dbFile);
2829
}
30+
parent::tearDown();
2931
}
3032

3133
protected function getPersistentSqliteDsn()

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage;
1313

1414
use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag;
15+
use Symfony\Component\HttpFoundation\Tests\ClockMockTestCase;
1516

1617
/**
1718
* Test class for MetadataBag.
1819
*/
19-
class MetadataBagTest extends \PHPUnit_Framework_TestCase
20+
class MetadataBagTest extends ClockMockTestCase
2021
{
2122
/**
2223
* @var MetadataBag
@@ -30,6 +31,7 @@ class MetadataBagTest extends \PHPUnit_Framework_TestCase
3031

3132
protected function setUp()
3233
{
34+
parent::setUp();
3335
$this->bag = new MetadataBag();
3436
$this->array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0);
3537
$this->bag->initialize($this->array);
@@ -39,6 +41,7 @@ protected function tearDown()
3941
{
4042
$this->array = array();
4143
$this->bag = null;
44+
parent::tearDown();
42< 4607 /code>45
}
4346

4447
public function testInitialize()

0 commit comments

Comments
 (0)
0