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

Skip to content

Commit b387477

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: 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 [Console] Fixed notice in DialogHelper [HttpFoundation] Fixed Request::getPort returns incorrect value under IPv6 [Filesystem] Fix test suite on OSX Add framework-bundle Conflicts: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
2 parents 75179c7 + eeeae94 commit b387477

File tree

12 files changed

+54
-27
lines changed

12 files changed

+54
-27
lines changed

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ protected function createEntityManagerMock($repositoryMock)
6363
->method('hasField')
6464
->will($this->returnValue(true))
6565
;
66-
$refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty')
66+
$reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser')
6767
->disableOriginalConstructor()
68+
->getMock()
69+
;
70+
$refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty')
71+
->setConstructorArgs(array($reflParser, 'property-name'))
6872
->setMethods(array('getValue'))
6973
->getMock()
7074
;

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"require-dev": {
2424
"symfony/stopwatch": "~2.2",
2525
"symfony/dependency-injection": "~2.0",
26-
"symfony/config": "~2.2"
26+
"symfony/config": "~2.2",
27+
"symfony/framework-bundle": "~2.1"
2728
},
2829
"autoload": {
2930
"psr-0": { "Symfony\\Bundle\\TwigBundle\\": "" }

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function ask(OutputInterface $output, $question, $default = null, array $
154154
$c .= fread($inputStream, 2);
155155

156156
// A = Up Arrow. B = Down Arrow
157-
if ('A' === $c[2] || 'B' === $c[2]) {
157+
if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
158158
if ('A' === $c[2] && -1 === $ofs) {
159159
$ofs = 0;
160160
}

src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ private function buildSizesFiltering(Command $command, array $sizes)
256256
case '!=':
257257
$command->add('-size -'.$size->getTarget().'c');
258258
$command->add('-size +'.$size->getTarget().'c');
259+
break;
259260
case '<':
260261
default:
261262
$command->add('-size -'.$size->getTarget().'c');

src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function createUploadedFileMock($name, $originalName, $valid)
5959
{
6060
$file = $this
6161
->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
62-
->disableOriginalConstructor()
62+
->setConstructorArgs(array(__DIR__.'/../../../Fixtures/foo', 'foo'))
6363
->getMock()
6464
;
6565
$file

src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function getRequestHandler()
4848
protected function getMockFile()
4949
{
5050
return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
51-
->disableOriginalConstructor()
51+
->setConstructorArgs(array(__DIR__.'/../../Fixtures/foo', 'foo'))
5252
->getMock();
5353
}
5454
}

src/Symfony/Component/HttpFoundation/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

src/Symfony/Component/HttpFoundation/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();

src/Symfony/Component/HttpFoundation/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());

src/Symfony/Component/HttpFoundation/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
}

src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testValidMimeType()
161161
{
162162
$file = $this
163163
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
164-
->disableOriginalConstructor()
164+
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
165165
->getMock()
166166
;
167167
$file
@@ -189,7 +189,7 @@ public function testValidWildcardMimeType()
189189
{
190190
$file = $this
191191
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
192-
->disableOriginalConstructor()
192+
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
193193
->getMock()
194194
;
195195
$file
@@ -217,7 +217,7 @@ public function testInvalidMimeType()
217217
{
218218
$file = $this
219219
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
220-
->disableOriginalConstructor()
220+
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
221221
->getMock()
222222
;
223223
$file
@@ -251,7 +251,7 @@ public function testInvalidWildcardMimeType()
251251
{
252252
$file = $this
253253
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
254-
->disableOriginalConstructor()
254+
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
255255
->getMock()
256256
;
257257
$file

src/Symfony/Component/Validator/Tests/Constraints/Fixtures/foo

Whitespace-only changes.

0 commit comments

Comments
 (0)
0