Skip to content

Commit 4beadfd

Browse files
committed
fixes deprecations for phpunit 5.4
1 parent 945e406 commit 4beadfd

File tree

14 files changed

+168
-199
lines changed

14 files changed

+168
-199
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@ php:
88
- 5.6
99
- 7.0
1010

11-
matrix:
12-
allow_failures:
13-
- php: 7.0
14-
1511
services: mongodb
1612

1713
before_install:
1814
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo 'extension=mongo.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
19-
- if [[ "$TRAVIS_PHP_VERSION" != 5.* ]]; then composer remove doctrine/mongodb-odm --no-update --dev; fi
15+
- if [[ "$TRAVIS_PHP_VERSION" != 5.* ]]; then echo 'extension=mongodb.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
16+
- if [[ "$TRAVIS_PHP_VERSION" != 5.* ]]; then cp composer7.json composer.json; fi
2017

2118
install:
2219
- composer install --prefer-dist

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@
4646
"doctrine/mongodb-odm": ">=1.0.2",
4747
"doctrine/orm": ">=2.5.0",
4848
"doctrine/common": ">=2.5.0",
49-
"symfony/yaml": "~2.6",
50-
"phpunit/phpunit": "~4.4",
51-
"phpunit/phpunit-mock-objects": "~2.3"
49+
"symfony/yaml": "~2.6|~3.0",
50+
"phpunit/phpunit": "*"
5251
},
5352
"suggest": {
5453
"doctrine/mongodb-odm": "to use the extensions with the MongoDB ODM",

composer7.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"name": "gedmo/doctrine-extensions",
3+
"type": "library",
4+
"description": "Doctrine2 behavioral extensions",
5+
"keywords": [
6+
"behaviors",
7+
"doctrine2",
8+
"extensions",
9+
"gedmo",
10+
"sluggable",
11+
"loggable",
12+
"translatable",
13+
"tree",
14+
"nestedset",
15+
"sortable",
16+
"timestampable",
17+
"blameable",
18+
"uploadable"
19+
],
20+
"homepage": "http://gediminasm.org/",
21+
"license": "MIT",
22+
"authors": [
23+
{
24+
"name": "Gediminas Morkevicius",
25+
"email": "[email protected]"
26+
},
27+
{
28+
"name": "Gustavo Falco",
29+
"email": "[email protected]"
30+
},
31+
{
32+
"name": "David Buchmann",
33+
"email": "[email protected]"
34+
}
35+
],
36+
"support": {
37+
"email": "[email protected]",
38+
"wiki": "https://github.com/Atlantic18/DoctrineExtensions/tree/master/doc"
39+
},
40+
"require": {
41+
"php": ">=5.4",
42+
"behat/transliterator": "~1.0",
43+
"doctrine/common": "~2.4"
44+
},
45+
"replace": {
46+
"ext-mongo": "1.6.12"
47+
},
48+
"require-dev": {
49+
"alcaeus/mongo-php-adapter": "~1.0.4",
50+
"doctrine/mongodb-odm": "~1.0",
51+
"doctrine/orm": ">=2.5.0",
52+
"doctrine/common": ">=2.5.0",
53+
"symfony/yaml": "~2.6|~3.0",
54+
"phpunit/phpunit": "*"
55+
},
56+
"suggest": {
57+
"doctrine/mongodb-odm": "to use the extensions with the MongoDB ODM",
58+
"doctrine/orm": "to use the extensions with the ORM"
59+
},
60+
"autoload": {
61+
"psr-0": { "Gedmo\\": "lib/" }
62+
},
63+
"config": {
64+
"bin-dir": "bin"
65+
},
66+
"extra": {
67+
"branch-alias": {
68+
"dev-master": "3.0.x-dev"
69+
}
70+
}
71+
}

tests/Gedmo/SoftDeleteable/SoftDeleteableDocumentTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,13 @@ public function shouldSupportSoftDeleteableFilterTimeAware()
158158
}
159159
public function testPostSoftDeleteEventIsDispatched()
160160
{
161-
$subscriber = $this->getMock(
162-
"Doctrine\Common\EventSubscriber",
163-
array(
161+
$subscriber = $this->getMockBuilder("Doctrine\Common\EventSubscriber")
162+
->setMethods(array(
164163
"getSubscribedEvents",
165164
"preSoftDelete",
166165
"postSoftDelete",
167-
)
168-
);
166+
))
167+
->getMock();
169168

170169
$subscriber->expects($this->once())
171170
->method("getSubscribedEvents")

tests/Gedmo/SoftDeleteable/SoftDeleteableEntityTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,20 @@ public function testSoftDeleteableFilter()
320320

321321
public function testPostSoftDeleteEventIsDispatched()
322322
{
323-
$subscriber = $this->getMock(
324-
"Doctrine\Common\EventSubscriber",
325-
array(
323+
$subscriber = $this->getMockBuilder("Doctrine\Common\EventSubscriber")
324+
->setMethods(array(
326325
"getSubscribedEvents",
327326
"preSoftDelete",
328327
"postSoftDelete",
329-
)
330-
);
328+
))
329+
->getMock();
331330

332331
$subscriber->expects($this->once())
333332
->method("getSubscribedEvents")
334-
->will($this->returnValue(array(SoftDeleteableListener::PRE_SOFT_DELETE, SoftDeleteableListener::POST_SOFT_DELETE)));
333+
->will($this->returnValue(array(
334+
SoftDeleteableListener::PRE_SOFT_DELETE,
335+
SoftDeleteableListener::POST_SOFT_DELETE
336+
)));
335337

336338
$subscriber->expects($this->exactly(2))
337339
->method("preSoftDelete")

tests/Gedmo/Tool/BaseTestCaseMongoODM.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function getMockDocumentManager(EventManager $evm = null, $config = nu
8989
*/
9090
protected function getMockMappedDocumentManager(EventManager $evm = null, $config = null)
9191
{
92-
$conn = $this->getMock('Doctrine\\MongoDB\\Connection');
92+
$conn = $this->getMockBuilder('Doctrine\\MongoDB\\Connection')->getMock();
9393

9494
$config = $config ? $config : $this->getMockAnnotatedConfig();
9595

tests/Gedmo/Tool/BaseTestCaseOM.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function getMockDocumentManager($dbName, MappingDriver $mappingDriver
111111
*/
112112
protected function getMockMappedDocumentManager($dbName, MappingDriver $mappingDriver = null)
113113
{
114-
$conn = $this->getMock('Doctrine\\MongoDB\\Connection');
114+
$conn = $this->getMockBuilder('Doctrine\\MongoDB\\Connection')->getMock();
115115
$config = $this->getMockAnnotatedODMMongoDBConfig($dbName, $mappingDriver);
116116

117117
$dm = DocumentManager::create($conn, $config, $this->getEventManager());
@@ -160,20 +160,21 @@ protected function getMockSqliteEntityManager(array $fixtures, MappingDriver $ma
160160
*/
161161
protected function getMockMappedEntityManager(MappingDriver $mappingDriver = null)
162162
{
163-
$driver = $this->getMock('Doctrine\DBAL\Driver');
163+
$driver = $this->getMockBuilder('Doctrine\DBAL\Driver')->getMock();
164164
$driver->expects($this->once())
165165
->method('getDatabasePlatform')
166-
->will($this->returnValue($this->getMock('Doctrine\DBAL\Platforms\MySqlPlatform')));
166+
->will($this->returnValue($this->getMockBuilder('Doctrine\DBAL\Platforms\MySqlPlatform')->getMock()));
167+
168+
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
169+
->setConstructorArgs(array(), $driver)
170+
->getMock();
167171

168-
$conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(array(), $driver));
169172
$conn->expects($this->once())
170173
->method('getEventManager')
171-
->will($this->returnValue($this->getEventManager()));
172-
173-
$config = $this->getMockAnnotatedORMConfig($mappingDriver);
174-
$em = EntityManager::create($conn, $config);
174+
->will($this->returnValue($evm ?: $this->getEventManager()));
175175

176-
return $em;
176+
$config = $this->getMockAnnotatedConfig();
177+
return EntityManager::create($conn, $config);
177178
}
178179

179180
/**
@@ -298,7 +299,7 @@ private function getMockAnnotatedODMMongoDBConfig($dbName, MappingDriver $mappin
298299
*/
299300
private function getMockAnnotatedORMConfig(MappingDriver $mappingDriver = null)
300301
{
301-
$config = $this->getMock('Doctrine\ORM\Configuration');
302+
$config = $this->getMockBuilder('Doctrine\ORM\Configuration')->getMock();
302303
$config->expects($this->once())
303304
->method('getProxyDir')
304305
->will($this->returnValue(__DIR__.'/../../temp'));

tests/Gedmo/Tool/BaseTestCaseORM.php

Lines changed: 11 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,15 @@ protected function getMockCustomEntityManager(array $conn, EventManager $evm = n
112112
*/
113113
protected function getMockMappedEntityManager(EventManager $evm = null)
114114
{
115-
$driver = $this->getMock('Doctrine\DBAL\Driver');
115+
$driver = $this->getMockBuilder('Doctrine\DBAL\Driver')->getMock();
116116
$driver->expects($this->once())
117117
->method('getDatabasePlatform')
118-
->will($this->returnValue($this->getMock('Doctrine\DBAL\Platforms\MySqlPlatform')));
118+
->will($this->returnValue($this->getMockBuilder('Doctrine\DBAL\Platforms\MySqlPlatform')->getMock()));
119+
120+
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
121+
->setConstructorArgs(array(), $driver)
122+
->getMock();
119123

120-
$conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(array(), $driver));
121124
$conn->expects($this->once())
122125
->method('getEventManager')
123126
->will($this->returnValue($evm ?: $this->getEventManager()));
@@ -139,11 +142,7 @@ protected function startQueryLog()
139142
throw new \RuntimeException('EntityManager and database platform must be initialized');
140143
}
141144
$this->queryAnalyzer = new QueryAnalyzer($this->em->getConnection()->getDatabasePlatform());
142-
$this->em
143-
->getConfiguration()
144-
->expects($this->any())
145-
->method('getSQLLogger')
146-
->will($this->returnValue($this->queryAnalyzer));
145+
$this->em->getConfiguration()->setSQLLogger($this->queryAnalyzer);
147146
}
148147

149148
/**
@@ -215,84 +214,10 @@ private function getEventManager()
215214
*/
216215
protected function getMockAnnotatedConfig()
217216
{
218-
// We need to mock every method except the ones which
219-
// handle the filters
220-
$configurationClass = 'Doctrine\ORM\Configuration';
221-
$refl = new \ReflectionClass($configurationClass);
222-
$methods = $refl->getMethods();
223-
224-
$mockMethods = array();
225-
226-
foreach ($methods as $method) {
227-
if ($method->name !== 'addFilter' && $method->name !== 'getFilterClassName') {
228-
$mockMethods[] = $method->name;
229-
}
230-
}
231-
232-
$config = $this->getMock($configurationClass, $mockMethods);
233-
234-
$config
235-
->expects($this->once())
236-
->method('getProxyDir')
237-
->will($this->returnValue(__DIR__.'/../../temp'))
238-
;
239-
240-
$config
241-
->expects($this->once())
242-
->method('getProxyNamespace')
243-
->will($this->returnValue('Proxy'))
244-
;
245-
246-
$config
247-
->expects($this->any())
248-
->method('getDefaultQueryHints')
249-
->will($this->returnValue(array()))
250-
;
251-
252-
$config
253-
->expects($this->once())
254-
->method('getAutoGenerateProxyClasses')
255-
->will($this->returnValue(true))
256-
;
257-
258-
$config
259-
->expects($this->once())
260-
->method('getClassMetadataFactoryName')
261-
->will($this->returnValue('Doctrine\\ORM\\Mapping\\ClassMetadataFactory'))
262-
;
263-
264-
$mappingDriver = $this->getMetadataDriverImplementation();
265-
266-
$config
267-
->expects($this->any())
268-
->method('getMetadataDriverImpl')
269-
->will($this->returnValue($mappingDriver))
270-
;
271-
272-
$config
273-
->expects($this->any())
274-
->method('getDefaultRepositoryClassName')
275-
->will($this->returnValue('Doctrine\\ORM\\EntityRepository'))
276-
;
277-
278-
$config
279-
->expects($this->any())
280-
->method('getQuoteStrategy')
281-
->will($this->returnValue(new DefaultQuoteStrategy()))
282-
;
283-
284-
$config
285-
->expects($this->any())
286-
->method('getNamingStrategy')
287-
->will($this->returnValue(new DefaultNamingStrategy()))
288-
;
289-
290-
$config
291-
->expects($this->once())
292-
->method('getRepositoryFactory')
293-
->will($this->returnValue(new DefaultRepositoryFactory()))
294-
;
295-
217+
$config = new Configuration();
218+
$config->setProxyDir(__DIR__.'/../../temp');
219+
$config->setProxyNamespace('Proxy');
220+
$config->setMetadataDriverImpl($this->getMetadataDriverImplementation());
296221
return $config;
297222
}
298223
}

tests/Gedmo/Translatable/Issue/Issue109Test.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ protected function setUp()
4242

4343
public function testIssue109()
4444
{
45-
$this->em
46-
->getConfiguration()
47-
->expects($this->any())
48-
->method('getCustomHydrationMode')
49-
->with(TranslationWalker::HYDRATE_OBJECT_TRANSLATION)
50-
->will($this->returnValue('Gedmo\\Translatable\\Hydrator\\ORM\\ObjectHydrator'))
51-
;
45+
$this->em->getConfiguration()->addCustomHydrationMode(
46+
TranslationWalker::HYDRATE_OBJECT_TRANSLATION,
47+
'Gedmo\\Translatable\\Hydrator\\ORM\\ObjectHydrator'
48+
);
5249
$query = $this->em->createQueryBuilder();
5350
$query->select('a')
5451
->from(self::ARTICLE, 'a')

tests/Gedmo/Translatable/Issue/Issue173Test.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ protected function setUp()
4343

4444
public function testIssue173()
4545
{
46-
$this->em
47-
->getConfiguration()
48-
->expects($this->any())
49-
->method('getCustomHydrationMode')
50-
->with(TranslationWalker::HYDRATE_OBJECT_TRANSLATION)
51-
->will($this->returnValue('Gedmo\\Translatable\\Hydrator\\ORM\\ObjectHydrator'))
52-
;
46+
$this->em->getConfiguration()->addCustomHydrationMode(
47+
TranslationWalker::HYDRATE_OBJECT_TRANSLATION,
48+
'Gedmo\\Translatable\\Hydrator\\ORM\\ObjectHydrator'
49+
);
5350

5451
$categories = $this->getCategoriesThatHasNoAssociations();
5552
$this->assertEquals(count($categories), 1, '$category3 has no associations');

0 commit comments

Comments
 (0)