From a12471d17126acc6a0975c2513bcc836fb79438d Mon Sep 17 00:00:00 2001 From: Clemens Tolboom Date: Sat, 7 Jun 2014 21:48:24 +0200 Subject: [PATCH 1/8] Add framework-bundle --- src/Symfony/Bundle/TwigBundle/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 65933fcf89..9144989930 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -23,7 +23,8 @@ "require-dev": { "symfony/stopwatch": "~2.2", "symfony/dependency-injection": "~2.0", - "symfony/config": "~2.2" + "symfony/config": "~2.2", + "symfony/framework-bundle": "~2.1" }, "autoload": { "psr-0": { "Symfony\\Bundle\\TwigBundle\\": "" } From e26f08e9b58b28745dc5c4661b7fbb8fa5bdc445 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 17 Jun 2014 03:04:39 +0200 Subject: [PATCH 2/8] [Filesystem] Fix test suite on OSX --- src/Symfony/Component/Filesystem/Tests/FilesystemTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 3484db9981..054ca7bbd4 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -981,6 +981,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase if ($datas = posix_getgrgid($infos['gid'])) { return $datas['name']; } + + $this->markTestSkipped('Unable to retrieve file group name'); } private function markAsSkippedIfSymlinkIsMissing() From 2a0e8e39b8482ac20a28e7753de40d5bea3fdede Mon Sep 17 00:00:00 2001 From: Keith Maika Date: Tue, 17 Jun 2014 09:10:30 -0400 Subject: [PATCH 3/8] [HttpFoundation] Fixed Request::getPort returns incorrect value under IPv6 Fixed issue with Request::getPort method returning an incorrect value when the HTTP_HOST header is a IPv6 address. --- src/Symfony/Component/HttpFoundation/Request.php | 8 +++++++- .../Component/HttpFoundation/Tests/RequestTest.php | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index ee4ca5d2dd..4a663093b8 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -932,7 +932,13 @@ class Request } if ($host = $this->headers->get('HOST')) { - if (false !== $pos = strrpos($host, ':')) { + if ($host[0] === '[') { + $pos = strpos($host, ':', strrpos($host, ']')); + } else { + $pos = strrpos($host, ':'); + } + + if (false !== $pos) { return intval(substr($host, $pos + 1)); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 111cb9e745..688f3094b9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -163,6 +163,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals(90, $request->getPort()); $this->assertTrue($request->isSecure()); + $request = Request::create('https://[::1]/foo'); + $this->assertEquals('https://[::1]/foo', $request->getUri()); + $this->assertEquals('/foo', $request->getPathInfo()); + $this->assertEquals('[::1]', $request->getHost()); + $this->assertEquals('[::1]', $request->getHttpHost()); + $this->assertEquals(443, $request->getPort()); + $this->assertTrue($request->isSecure()); + $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; $request = Request::create('http://example.com/jsonrpc', 'POST', array(), array(), array(), array(), $json); $this->assertEquals($json, $request->getContent()); From ff6c65ecf7b5845a370a2dc7037ce5198119fce5 Mon Sep 17 00:00:00 2001 From: florianv Date: Thu, 19 Jun 2014 01:02:32 +0200 Subject: [PATCH 4/8] [Console] Fixed notice in DialogHelper --- src/Symfony/Component/Console/Helper/DialogHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php index 6a442ea376..57f6a6f6b4 100644 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ b/src/Symfony/Component/Console/Helper/DialogHelper.php @@ -150,7 +150,7 @@ class DialogHelper extends Helper $c .= fread($inputStream, 2); // A = Up Arrow. B = Down Arrow - if ('A' === $c[2] || 'B' === $c[2]) { + if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) { if ('A' === $c[2] && -1 === $ofs) { $ofs = 0; } From 31b1dff8754ed707b6c7da9a57a99f2e412a00a3 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Fri, 20 Jun 2014 12:59:50 +0200 Subject: [PATCH 5/8] Small comment update according to PSR-2 See [PSR-2](http://www.php-fig.org/psr/psr-2/) paragraph 5.2 > There MUST be a comment such as `// no break` when fall-through is intentional in a non-empty case body. Related to #11181 --- src/Symfony/Component/HttpFoundation/Request.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 4a663093b8..d7053339bd 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -350,6 +350,7 @@ class Request if (!isset($server['CONTENT_TYPE'])) { $server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; } + // no break case 'PATCH': $request = $parameters; $query = array(); From 2c726b8988cf0fe53f9e46c066dce7990d72ec9b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 20 Jun 2014 15:25:51 +0200 Subject: [PATCH 6/8] don't disable constructor calls to mockups of classes that extend internal PHP classes --- .../Constraints/UniqueValidatorTest.php | 6 +++- .../Extension/Core/Type/FileTypeTest.php | 2 +- .../HttpFoundationRequestHandlerTest.php | 2 +- .../Tests/BinaryFileResponseTest.php | 8 ++--- .../Handler/MongoDbSessionHandlerTest.php | 32 +++++++++++-------- .../Tests/Constraints/FileValidatorTest.php | 8 ++--- .../Validator/Tests/Constraints/Fixtures/foo | 0 7 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 src/Symfony/Component/Validator/Tests/Constraints/Fixtures/foo diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php index 9d0a75af5e..9980802642 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php @@ -76,8 +76,12 @@ class UniqueValidatorTest extends \PHPUnit_Framework_TestCase ->method('hasField') ->will($this->returnValue(true)) ; - $refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty') + $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') ->disableOriginalConstructor() + ->getMock() + ; + $refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty') + ->setConstructorArgs(array($reflParser, 'property-name')) ->setMethods(array('getValue')) ->getMock() ; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php index 63556eb5a6..ed38ab2886 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php @@ -59,7 +59,7 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->disableOriginalConstructor() + ->setConstructorArgs(array(__DIR__.'/../../../Fixtures/foo', 'foo')) ->getMock() ; $file diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php index 2d5cf7764b..b25380aea7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php @@ -48,7 +48,7 @@ class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest protected function getMockFile() { return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->disableOriginalConstructor() + ->setConstructorArgs(array(__DIR__.'/../../Fixtures/foo', 'foo')) ->getMock(); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 69b099885a..d7d1b03c3c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -180,16 +180,16 @@ class BinaryFileResponseTest extends ResponseTestCase $request->headers->set('X-Accel-Mapping', $mapping); $file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() - ->getMock(); + ->setConstructorArgs(array(__DIR__.'/File/Fixtures/test')) + ->getMock(); $file->expects($this->any()) ->method('getRealPath') ->will($this->returnValue($realpath)); $file->expects($this->any()) ->method('isReadable') ->will($this->returnValue(true)); - $file->expects($this->any()) - ->method('getMTime') + $file->expects($this->any()) + ->method('getMTime') ->will($this->returnValue(time())); BinaryFileResponse::trustXSendFileTypeHeader(); 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 d168ce6379..9577d52478 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -34,7 +34,6 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? 'Mongo' : 'MongoClient'; $this->mongo = $this->getMockBuilder($mongoClass) - ->disableOriginalConstructor() ->getMock(); $this->options = array( @@ -76,9 +75,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testWrite() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -105,9 +102,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testReplaceSessionData() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -130,9 +125,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testDestroy() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -148,9 +141,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase public function testGc() { - $collection = $this->getMockBuilder('MongoCollection') - ->disableOriginalConstructor() - ->getMock(); + $collection = $this->createMongoCollectionMock(); $this->mongo->expects($this->once()) ->method('selectCollection') @@ -168,4 +159,19 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->storage->gc(-1)); } + + private function createMongoCollectionMock() + { + + $mongoClient = $this->getMockBuilder('MongoClient') + ->getMock(); + $mongoDb = $this->getMockBuilder('MongoDB') + ->setConstructorArgs(array($mongoClient, 'database-name')) + ->getMock(); + $collection = $this->getMockBuilder('MongoCollection') + ->setConstructorArgs(array($mongoDb, 'collection-name')) + ->getMock(); + + return $collection; + } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 0ca98067d3..fcbbb04b83 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -165,7 +165,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) ->getMock() ; $file @@ -193,7 +193,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) ->getMock() ; $file @@ -221,7 +221,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) ->getMock() ; $file @@ -255,7 +255,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase { $file = $this ->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->disableOriginalConstructor() + ->setConstructorArgs(array(__DIR__.'/Fixtures/foo')) ->getMock() ; $file diff --git a/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/foo b/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/foo new file mode 100644 index 0000000000..e69de29bb2 From 5af2802661c5aa7b89f533b1a839a81a844688c0 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Fri, 20 Jun 2014 16:24:06 +0200 Subject: [PATCH 7/8] Added missing `break` statement Added missing `break` statement in `AbstractFindAdapter` - a fall through doesn't seem to be intended here. --- src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php index 01940385de..5c7206240e 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php @@ -256,6 +256,7 @@ abstract class AbstractFindAdapter extends AbstractAdapter case '!=': $command->add('-size -'.$size->getTarget().'c'); $command->add('-size +'.$size->getTarget().'c'); + break; case '<': default: $command->add('-size -'.$size->getTarget().'c'); From f2bdc22b0d5ff3492d71cdc55581b3867de714a3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 20 Jun 2014 19:37:57 +0200 Subject: [PATCH 8/8] fixed previous merge --- src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php index b4b2230189..106c13fb50 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php @@ -96,6 +96,8 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase if ($datas = posix_getgrgid($infos['gid'])) { return $datas['name']; } + + $this->markTestSkipped('Unable to retrieve file group name'); } protected function markAsSkippedIfSymlinkIsMissing()