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')
|
->method('hasField')
|
||||||
->will($this->returnValue(true))
|
->will($this->returnValue(true))
|
||||||
;
|
;
|
||||||
$refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty')
|
$reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
->getMock()
|
||||||
|
;
|
||||||
|
$refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty')
|
||||||
|
->setConstructorArgs(array($reflParser, 'property-name'))
|
||||||
->setMethods(array('getValue'))
|
->setMethods(array('getValue'))
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
|
@ -59,7 +59,7 @@ class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
{
|
{
|
||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/../../../Fixtures/foo', 'foo'))
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
$file
|
$file
|
||||||
|
@ -48,7 +48,7 @@ class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
|
|||||||
protected function getMockFile()
|
protected function getMockFile()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
|
return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/../../Fixtures/foo', 'foo'))
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,8 @@ class BinaryFileResponseTest extends ResponseTestCase
|
|||||||
$request->headers->set('X-Accel-Mapping', $mapping);
|
$request->headers->set('X-Accel-Mapping', $mapping);
|
||||||
|
|
||||||
$file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
$file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/File/Fixtures/test'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$file->expects($this->any())
|
$file->expects($this->any())
|
||||||
->method('getRealPath')
|
->method('getRealPath')
|
||||||
->will($this->returnValue($realpath));
|
->will($this->returnValue($realpath));
|
||||||
|
@ -34,7 +34,6 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? 'Mongo' : 'MongoClient';
|
$mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? 'Mongo' : 'MongoClient';
|
||||||
|
|
||||||
$this->mongo = $this->getMockBuilder($mongoClass)
|
$this->mongo = $this->getMockBuilder($mongoClass)
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
@ -76,9 +75,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testWrite()
|
public function testWrite()
|
||||||
{
|
{
|
||||||
$collection = $this->getMockBuilder('MongoCollection')
|
$collection = $this->createMongoCollectionMock();
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$this->mongo->expects($this->once())
|
$this->mongo->expects($this->once())
|
||||||
->method('selectCollection')
|
->method('selectCollection')
|
||||||
@ -105,9 +102,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testReplaceSessionData()
|
public function testReplaceSessionData()
|
||||||
{
|
{
|
||||||
$collection = $this->getMockBuilder('MongoCollection')
|
$collection = $this->createMongoCollectionMock();
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$this->mongo->expects($this->once())
|
$this->mongo->expects($this->once())
|
||||||
->method('selectCollection')
|
->method('selectCollection')
|
||||||
@ -130,9 +125,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testDestroy()
|
public function testDestroy()
|
||||||
{
|
{
|
||||||
$collection = $this->getMockBuilder('MongoCollection')
|
$collection = $this->createMongoCollectionMock();
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$this->mongo->expects($this->once())
|
$this->mongo->expects($this->once())
|
||||||
->method('selectCollection')
|
->method('selectCollection')
|
||||||
@ -148,9 +141,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testGc()
|
public function testGc()
|
||||||
{
|
{
|
||||||
$collection = $this->getMockBuilder('MongoCollection')
|
$collection = $this->createMongoCollectionMock();
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$this->mongo->expects($this->once())
|
$this->mongo->expects($this->once())
|
||||||
->method('selectCollection')
|
->method('selectCollection')
|
||||||
@ -168,4 +159,19 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertTrue($this->storage->gc(-1));
|
$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
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
$file
|
$file
|
||||||
@ -193,7 +193,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
$file
|
$file
|
||||||
@ -221,7 +221,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
$file
|
$file
|
||||||
@ -255,7 +255,7 @@ abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$file = $this
|
$file = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
|
||||||
->disableOriginalConstructor()
|
->setConstructorArgs(array(__DIR__.'/Fixtures/foo'))
|
||||||
->getMock()
|
->getMock()
|
||||||
;
|
;
|
||||||
$file
|
$file
|
||||||
|
Reference in New Issue
Block a user