don't disable constructor calls to mockups of classes that extend internal PHP classes
This commit is contained in:
parent
7d4f4f276a
commit
2c726b8988
@ -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()
|
||||
;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -180,8 +180,8 @@ 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));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user