Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1948d36

Browse filesBrowse files
committed
Merge branch '2.4'
* 2.4: Revert "[HttpFoundation] removed test file not related to 2.3" [HttpFoundation] removed test file not related to 2.3 [HttpKernel] fixed CS Add tests for RequestStack class
2 parents f6bc83f + 91ceddc commit 1948d36
Copy full SHA for 1948d36

File tree

Expand file treeCollapse file tree

3 files changed

+81
-16
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+81
-16
lines changed
+69Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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\HttpFoundation\Tests;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\RequestStack;
16+
17+
class RequestStackTest extends \PHPUnit_Framework_TestCase
18+
{
19+
public function testGetCurrentRequest()
20+
{
21+
$requestStack = new RequestStack();
22+
$this->assertNull($requestStack->getCurrentRequest());
23+
24+
$request = Request::create('/foo');
25+
26+
$requestStack->push($request);
27+
$this->assertSame($request, $requestStack->getCurrentRequest());
28+
29+
$this->assertSame($request, $requestStack->pop());
30+
$this->assertNull($requestStack->getCurrentRequest());
31+
32+
$this->assertNull($requestStack->pop());
33+
}
34+
35+
public function testGetMasterRequest()
36+
{
37+
$requestStack = new RequestStack();
38+
$this->assertNull($requestStack->getMasterRequest());
39+
40+
$masterRequest = Request::create('/foo');
41+
$subRequest = Request::create('/bar');
42+
43+
$requestStack->push($masterRequest);
44+
$requestStack->push($subRequest);
45+
46+
$this->assertSame($masterRequest, $requestStack->getMasterRequest());
47+
}
48+
49+
public function testGetParentRequest()
50+
{
51+
$requestStack = new RequestStack();
52+
$this->assertNull($requestStack->getParentRequest());
53+
54+
$masterRequest = Request::create('/foo');
55+
56+
$requestStack->push($masterRequest);
57+
$this->assertNull($requestStack->getParentRequest());
58+
59+
$firstSubRequest = Request::create('/bar');
60+
61+
$requestStack->push($firstSubRequest);
62+
$this->assertSame($masterRequest, $requestStack->getParentRequest());
63+
64+
$secondSubRequest = Request::create('/baz');
65+
66+
$requestStack->push($secondSubRequest);
67+
$this->assertSame($firstSubRequest, $requestStack->getParentRequest());
68+
}
69+
}

‎src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\HttpKernel\Profiler;
1313

14-
use Memcache;
15-
1614
/**
1715
* Memcache Profiler Storage
1816
*
@@ -21,14 +19,14 @@
2119
class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage
2220
{
2321
/**
24-
* @var Memcache
22+
* @var \Memcache
2523
*/
2624
private $memcache;
2725

2826
/**
2927
* Internal convenience method that returns the instance of the Memcache
3028
*
31-
* @return Memcache
29+
* @return \Memcache
3230
*
3331
* @throws \RuntimeException
3432
*/
@@ -42,7 +40,7 @@ protected function getMemcache()
4240
$host = $matches[1] ?: $matches[2];
4341
$port = $matches[3];
4442

45-
$memcache = new Memcache();
43+
$memcache = new \Memcache();
4644
$memcache->addServer($host, $port);
4745

4846
$this->memcache = $memcache;
@@ -54,7 +52,7 @@ protected function getMemcache()
5452
/**
5553
* Set instance of the Memcache
5654
*
57-
* @param Memcache $memcache
55+
* @param \Memcache $memcache
5856
*/
5957
public function setMemcache($memcache)
6058
{
@@ -94,15 +92,15 @@ protected function appendValue($key, $value, $expiration = 0)
9492

9593
if (method_exists($memcache, 'append')) {
9694

97-
//Memcache v3.0
95+
// Memcache v3.0
9896
if (!$result = $memcache->append($key, $value, false, $expiration)) {
9997
return $memcache->set($key, $value, false, $expiration);
10098
}
10199

102100
return $result;
103101
}
104102

105-
//simulate append in Memcache <3.0
103+
// simulate append in Memcache <3.0
106104
$content = $memcache->get($key);
107105

108106
return $memcache->set($key, $content.$value, false, $expiration);

‎src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\HttpKernel\Profiler;
1313

14-
use Memcached;
15-
1614
/**
1715
* Memcached Profiler Storage
1816
*
@@ -21,14 +19,14 @@
2119
class MemcachedProfilerStorage extends BaseMemcacheProfilerStorage
2220
{
2321
/**
24-
* @var Memcached
22+
* @var \Memcached
2523
*/
2624
private $memcached;
2725

2826
/**
2927
* Internal convenience method that returns the instance of the Memcached
3028
*
31-
* @return Memcached
29+
* @return \Memcached
3230
*
3331
* @throws \RuntimeException
3432
*/
@@ -42,10 +40,10 @@ protected function getMemcached()
4240
$host = $matches[1] ?: $matches[2];
4341
$port = $matches[3];
4442

45-
$memcached = new Memcached();
43+
$memcached = new \Memcached();
4644

47-
//disable compression to allow appending
48-
$memcached->setOption(Memcached::OPT_COMPRESSION, false);
45+
// disable compression to allow appending
46+
$memcached->setOption(\Memcached::OPT_COMPRESSION, false);
4947

5048
$memcached->addServer($host, $port);
5149

@@ -58,7 +56,7 @@ protected function getMemcached()
5856
/**
5957
* Set instance of the Memcached
6058
*
61-
* @param Memcached $memcached
59+
* @param \Memcached $memcached
6260
*/
6361
public function setMemcached($memcached)
6462
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.