Skip to content

Commit ba31531

Browse files
authored
Merge pull request #710 from doctrine/do_not_use_get_mock
Use getMockBuilder instead of getMock
2 parents 8168015 + 5e26996 commit ba31531

File tree

9 files changed

+31
-28
lines changed

9 files changed

+31
-28
lines changed

tests/Doctrine/Tests/ODM/PHPCR/DocumentManagerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testFindTranslation()
5454
*/
5555
public function testNewInstanceFromConfiguration()
5656
{
57-
$session = $this->getMock('PHPCR\SessionInterface');
57+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
5858
$config = new \Doctrine\ODM\PHPCR\Configuration();
5959

6060
$dm = DocumentManager::create($session, $config);
@@ -68,7 +68,7 @@ public function testNewInstanceFromConfiguration()
6868
*/
6969
public function testGetMetadataFactory()
7070
{
71-
$session = $this->getMock('PHPCR\SessionInterface');
71+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
7272

7373
$dm = DocumentManager::create($session);
7474

@@ -80,7 +80,7 @@ public function testGetMetadataFactory()
8080
*/
8181
public function testGetClassMetadataFor()
8282
{
83-
$session = $this->getMock('PHPCR\SessionInterface');
83+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
8484

8585
$dm = DocumentManager::create($session);
8686

@@ -95,7 +95,7 @@ public function testGetClassMetadataFor()
9595
*/
9696
public function testContains()
9797
{
98-
$session = $this->getMock('PHPCR\SessionInterface');
98+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
9999

100100
$dm = DocumentManager::create($session);
101101

@@ -115,7 +115,7 @@ public function testContains()
115115
*/
116116
public function testGetRepository()
117117
{
118-
$session = $this->getMock('PHPCR\SessionInterface');
118+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
119119

120120
$dm = new DocumentManagerGetClassMetadata($session);
121121

@@ -131,7 +131,7 @@ public function testGetRepository()
131131
*/
132132
public function testEscapeFullText()
133133
{
134-
$session = $this->getMock('PHPCR\SessionInterface');
134+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
135135

136136
$dm = DocumentManager::create($session);
137137

@@ -144,11 +144,11 @@ public function testEscapeFullText()
144144
*/
145145
public function testCreateQueryBuilder()
146146
{
147-
$session = $this->getMock('PHPCR\SessionInterface');
148-
$workspace = $this->getMock('PHPCR\WorkspaceInterface');
149-
$queryManager = $this->getMock('PHPCR\Query\QueryManagerInterface');
150-
$qomf = $this->getMock('PHPCR\Query\QOM\QueryObjectModelFactoryInterface');
151-
$baseQuery = $this->getMock('PHPCR\Query\QueryInterface');
147+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
148+
$workspace = $this->getMockBuilder('PHPCR\WorkspaceInterface')->getMock();
149+
$queryManager = $this->getMockBuilder('PHPCR\Query\QueryManagerInterface')->getMock();
150+
$qomf = $this->getMockBuilder('PHPCR\Query\QOM\QueryObjectModelFactoryInterface')->getMock();
151+
$baseQuery = $this->getMockBuilder('PHPCR\Query\QueryInterface')->getMock();
152152

153153
$session->expects($this->once())
154154
->method('getWorkspace')

tests/Doctrine/Tests/ODM/PHPCR/Id/RepositoryIdGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function testGenerate()
1212
{
1313
$id = 'moo';
1414
$cm = new RepositoryClassMetadataProxy($id);
15-
$repository = $this->getMock('Doctrine\ODM\PHPCR\Id\RepositoryIdInterface');
15+
$repository = $this->getMockBuilder('Doctrine\ODM\PHPCR\Id\RepositoryIdInterface')->getMock();
1616
$repository
1717
->expects($this->once())
1818
->method('generateId')
@@ -39,7 +39,7 @@ public function testGenerateNoIdException()
3939
$id = 'moo';
4040
$generator = new RepositoryIdGenerator;
4141
$cm = new ClassMetadataProxy($id);
42-
$repository = $this->getMock('Doctrine\ODM\PHPCR\Id\RepositoryIdInterface');
42+
$repository = $this->getMockBuilder('Doctrine\ODM\PHPCR\Id\RepositoryIdInterface')->getMock();
4343
$repository
4444
->expects($this->once())
4545
->method('generateId')

tests/Doctrine/Tests/ODM/PHPCR/Mapping/AbstractMappingDriverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public function testParentWithPrivatePropertyMapping()
348348
$this->assertTrue(isset($class->identifier));
349349
$this->assertEmpty($class->fieldMappings);
350350

351-
$session = $this->getMock('PHPCR\SessionInterface');
351+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
352352
$dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session);
353353
$dm->getConfiguration()->setMetadataDriverImpl($this->loadDriver());
354354
$cmf = new ClassMetadataFactory($dm);
@@ -756,7 +756,7 @@ public function testStringExtendedMapping()
756756
$this->loadMetadataForClassname($className);
757757

758758
$className = 'Doctrine\Tests\ODM\PHPCR\Mapping\Model\StringExtendedMappingObject';
759-
$session = $this->getMock('PHPCR\SessionInterface');
759+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
760760
$dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session);
761761
$dm->getConfiguration()->setMetadataDriverImpl($this->loadDriver());
762762
$cmf = new ClassMetadataFactory($dm);

tests/Doctrine/Tests/ODM/PHPCR/Mapping/ClassMetadataFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function getMetadataFor($fqn)
3535

3636
public function setUp()
3737
{
38-
$session = $this->getMock('PHPCR\SessionInterface');
38+
$session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
3939
$this->dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session);
4040
}
4141

tests/Doctrine/Tests/ODM/PHPCR/Query/Builder/ConverterPhpcrTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function setUp()
1919
$me = $this;
2020
// note: this "factory" seems unnecessary in current jackalope
2121
// implementation
22-
$this->qomfFactory = $this->getMock('Jackalope\FactoryInterface');
22+
$this->qomfFactory = $this->getMockBuilder('Jackalope\FactoryInterface')->getMock();
2323

2424
$this->qomf = new QueryObjectModelFactory($this->qomfFactory);
2525

@@ -651,7 +651,7 @@ public function testGetQuery()
651651
);
652652

653653
// return something ..
654-
$qom = $me->getMock('PHPCR\Query\QOM\QueryObjectModelInterface');
654+
$qom = $me->getMockBuilder('PHPCR\Query\QOM\QueryObjectModelInterface')->getMock();
655655
return $qom;
656656
}));
657657

tests/Doctrine/Tests/ODM/PHPCR/Query/Builder/QueryBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testCloningQueryBuilderUniqueConverterInstance()
107107
$property = $reflection->getProperty('converter');
108108
$property->setAccessible(true);
109109

110-
$this->node->setConverter($this->getMock('Doctrine\ODM\PHPCR\Query\Builder\ConverterInterface'));
110+
$this->node->setConverter($this->getMockBuilder('Doctrine\ODM\PHPCR\Query\Builder\ConverterInterface')->getMock());
111111

112112
$clone = clone $this->node;
113113

tests/Doctrine/Tests/ODM/PHPCR/Query/QueryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class QueryTest extends \PHPUnit_Framework_Testcase
1111
{
1212
public function setUp()
1313
{
14-
$this->phpcrQuery = $this->getMock('PHPCR\Query\QueryInterface');
14+
$this->phpcrQuery = $this->getMockBuilder('PHPCR\Query\QueryInterface')->getMock();
1515
$this->dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager')
1616
->disableOriginalConstructor()
1717
->getMock();
18-
$this->arrayCollection = $this->getMock('Doctrine\Common\Collections\ArrayCollection');
18+
$this->arrayCollection = $this->getMockBuilder('Doctrine\Common\Collections\ArrayCollection')->getMock();
1919
$this->query = new Query($this->phpcrQuery, $this->dm);
2020
$this->aliasQuery = new Query($this->phpcrQuery, $this->dm, 'a');
2121
}

tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DocumentConvertTranslationCommandTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ class DocumentConvertTranslationCommandTest extends \PHPUnit_Framework_TestCase
3232

3333
public function setUp()
3434
{
35-
$this->mockSession = $this->getMock('PHPCR\SessionInterface');
36-
$mockHelper = $this->getMock(
37-
'Symfony\Component\Console\Helper\HelperInterface',
38-
array('getSession', 'setHelperSet', 'getHelperSet', 'getName')
39-
);
35+
$this->mockSession = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
36+
$mockHelper = $this->getMockBuilder('PHPCR\Util\Console\Helper\PhpcrHelper')
37+
->disableOriginalConstructor()
38+
->getMock();
4039
$mockHelper
4140
->expects($this->once())
4241
->method('getSession')

tests/Doctrine/Tests/ODM/PHPCR/UnitOfWorkTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ public function setUp()
3636
}
3737

3838
$this->factory = new Factory;
39-
$this->session = $this->getMock('Jackalope\Session', array(), array($this->factory), '', false);
39+
$this->session = $this->getMockBuilder('Jackalope\Session')
40+
->disableOriginalConstructor()
41+
->getMock();
4042

41-
$this->objectManager = $this->getMock('Jackalope\ObjectManager', array(), array($this->factory), '', false);
43+
$this->objectManager = $this->getMockBuilder('Jackalope\ObjectManager')
44+
->disableOriginalConstructor()
45+
->getMock();
4246

4347
$this->type = 'Doctrine\Tests\ODM\PHPCR\UoWUser';
4448
$this->dm = DocumentManager::create($this->session);

0 commit comments

Comments
 (0)