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
This commit is contained in:
Fabien Potencier 2014-06-20 19:36:47 +02:00
commit b387477d51
12 changed files with 54 additions and 27 deletions

View File

@ -63,8 +63,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()
;

View File

@ -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\\": "" }

View File

@ -154,7 +154,7 @@ class DialogHelper extends InputAwareHelper
$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;
}

View File

@ -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');

View File

@ -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

View File

@ -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();
}
}

View File

@ -358,6 +358,7 @@ class Request
if (!isset($server['CONTENT_TYPE'])) {
$server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
}
// no break
case 'PATCH':
$request = $parameters;
$query = array();
@ -955,7 +956,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));
}

View File

@ -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();

View File

@ -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());

View File

@ -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')
@ -178,4 +169,19 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf($mongoClass, $method->invoke($this->storage));
}
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;
}
}

View File

@ -161,7 +161,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
{
$file = $this
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
->disableOriginalConstructor()
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
->getMock()
;
$file
@ -189,7 +189,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
{
$file = $this
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
->disableOriginalConstructor()
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
->getMock()
;
$file
@ -217,7 +217,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
{
$file = $this
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
->disableOriginalConstructor()
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
->getMock()
;
$file
@ -251,7 +251,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
{
$file = $this
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
->disableOriginalConstructor()
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
->getMock()
;
$file