Skip to content

Commit 6b3bf91

Browse files
committed
Merge branch '2.5'
* 2.5: fixed previous merge Added missing `break` statement don't disable constructor calls to mockups of classes that extend internal PHP classes Small comment update according to PSR-2 [Yaml] fix overwriting of keys after merged map [Yaml] fix priority of sequence merges according to spec [Console] Fixed notice in QuestionHelper [Console] Fixed notice in DialogHelper [Yaml] refactoring of merges for performance [Console] remove weird use statement [HttpFoundation] Fixed Request::getPort returns incorrect value under IPv6 [Filesystem] Fix test suite on OSX [FrameworkBundle] Redirect server output to /dev/null in case no verbosity is needed Add framework-bundle Conflicts: src/Symfony/Component/Yaml/Parser.php
2 parents a2b9d7a + 69f0f70 commit 6b3bf91

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

Request.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ public static function create($uri, $method = 'GET', $parameters = array(), $coo
358358
if (!isset($server['CONTENT_TYPE'])) {
359359
$server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
360360
}
361+
// no break
361362
case 'PATCH':
362363
$request = $parameters;
363364
$query = array();
@@ -955,7 +956,13 @@ public function getPort()
955956
}
956957

957958
if ($host = $this->headers->get('HOST')) {
958-
if (false !== $pos = strrpos($host, ':')) {
959+
if ($host[0] === '[') {
960+
$pos = strpos($host, ':', strrpos($host, ']'));
961+
} else {
962+
$pos = strrpos($host, ':');
963+
}
964+
965+
if (false !== $pos) {
959966
return intval(substr($host, $pos + 1));
960967
}
961968

Tests/BinaryFileResponseTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,16 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
180180
$request->headers->set('X-Accel-Mapping', $mapping);
181181

182182
$file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
183-
->disableOriginalConstructor()
184-
->getMock();
183+
->setConstructorArgs(array(__DIR__.'/File/Fixtures/test'))
184+
->getMock();
185185
$file->expects($this->any())
186186
->method('getRealPath')
187187
->will($this->returnValue($realpath));
188188
$file->expects($this->any())
189189
->method('isReadable')
190190
->will($this->returnValue(true));
191-
$file->expects($this->any())
192-
->method('getMTime')
191+
$file->expects($this->any())
192+
->method('getMTime')
193193
->will($this->returnValue(time()));
194194

195195
BinaryFileResponse::trustXSendFileTypeHeader();

Tests/RequestTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ public function testCreate()
163163
$this->assertEquals(90, $request->getPort());
164164
$this->assertTrue($request->isSecure());
165165

166+
$request = Request::create('https://[::1]/foo');
167+
$this->assertEquals('https://[::1]/foo', $request->getUri());
168+
$this->assertEquals('/foo', $request->getPathInfo());
169+
$this->assertEquals('[::1]', $request->getHost());
170+
$this->assertEquals('[::1]', $request->getHttpHost());
171+
$this->assertEquals(443, $request->getPort());
172+
$this->assertTrue($request->isSecure());
173+
166174
$json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}';
167175
$request = Request::create('http://example.com/jsonrpc', 'POST', array(), array(), array(), array(), $json);
168176
$this->assertEquals($json, $request->getContent());

Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ protected function setUp()
3434
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? 'Mongo' : 'MongoClient';
3535

3636
$this->mongo = $this->getMockBuilder($mongoClass)
37-
->disableOriginalConstructor()
3837
->getMock();
3938

4039
$this->options = array(
@@ -76,9 +75,7 @@ public function testCloseMethodAlwaysReturnTrue()
7675

7776
public function testWrite()
7877
{
79-
$collection = $this->getMockBuilder('MongoCollection')
80-
->disableOriginalConstructor()
81-
->getMock();
78+
$collection = $this->createMongoCollectionMock();
8279

8380
$this->mongo->expects($this->once())
8481
->method('selectCollection')
@@ -105,9 +102,7 @@ public function testWrite()
105102

106103
public function testReplaceSessionData()
107104
{
108-
$collection = $this->getMockBuilder('MongoCollection')
109-
->disableOriginalConstructor()
110-
->getMock();
105+
$collection = $this->createMongoCollectionMock();
111106

112107
$this->mongo->expects($this->once())
113108
->method('selectCollection')
@@ -130,9 +125,7 @@ public function testReplaceSessionData()
130125

131126
public function testDestroy()
132127
{
133-
$collection = $this->getMockBuilder('MongoCollection')
134-
->disableOriginalConstructor()
135-
->getMock();
128+
$collection = $this->createMongoCollectionMock();
136129

137130
$this->mongo->expects($this->once())
138131
->method('selectCollection')
@@ -148,9 +141,7 @@ public function testDestroy()
148141

149142
public function testGc()
150143
{
151-
$collection = $this->getMockBuilder('MongoCollection')
152-
->disableOriginalConstructor()
153-
->getMock();
144+
$collection = $this->createMongoCollectionMock();
154145

155146
$this->mongo->expects($this->once())
156147
->method('selectCollection')
@@ -178,4 +169,19 @@ public function testGetConnection()
178169

179170
$this->assertInstanceOf($mongoClass, $method->invoke($this->storage));
180171
}
172+
173+
private function createMongoCollectionMock()
174+
{
175+
176+
$mongoClient = $this->getMockBuilder('MongoClient')
177+
->getMock();
178+
$mongoDb = $this->getMockBuilder('MongoDB')
179+
->setConstructorArgs(array($mongoClient, 'database-name'))
180+
->getMock();
181+
$collection = $this->getMockBuilder('MongoCollection')
182+
->setConstructorArgs(array($mongoDb, 'collection-name'))
183+
->getMock();
184+
185+
return $collection;
186+
}
181187
}

0 commit comments

Comments
 (0)