Skip to content

Commit 0532e47

Browse files
committed
adapts tests to pass with php 7
1 parent 4beadfd commit 0532e47

File tree

4 files changed

+24
-129
lines changed

4 files changed

+24
-129
lines changed

tests/Gedmo/Mapping/Driver/Yaml/Mapping.Fixture.Yaml.Category.dcm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ Mapping\Fixture\Yaml\Category:
3131
fields:
3232
- title
3333
handlers:
34-
"Gedmo\Sluggable\Handler\RelativeSlugHandler":
34+
Gedmo\Sluggable\Handler\RelativeSlugHandler:
3535
relationField: parent
3636
relationSlugField: slug
3737
separator: /
38-
"Gedmo\Sluggable\Handler\TreeSlugHandler":
38+
Gedmo\Sluggable\Handler\TreeSlugHandler:
3939
parentRelationField: parent
4040
separator: /
4141
changed:

tests/Gedmo/Tool/BaseTestCaseMongoODM.php

Lines changed: 10 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -132,75 +132,16 @@ private function getEventManager()
132132
*/
133133
protected function getMockAnnotatedConfig()
134134
{
135-
$config = $this->getMock('Doctrine\\ODM\\MongoDB\\Configuration');
136-
137-
$config->expects($this->any())
138-
->method('getFilterClassName')
139-
->will($this->returnValue('Gedmo\\SoftDeleteable\\Filter\\ODM\\SoftDeleteableFilter'));
140-
141-
$config->expects($this->any())
142-
->method('getFilterParameters')
143-
->will($this->returnValue(array()));
144-
145-
$config->expects($this->once())
146-
->method('getProxyDir')
147-
->will($this->returnValue(__DIR__.'/../../temp'));
148-
149-
$config->expects($this->once())
150-
->method('getProxyNamespace')
151-
->will($this->returnValue('Proxy'));
152-
153-
$config->expects($this->once())
154-
->method('getHydratorDir')
155-
->will($this->returnValue(__DIR__.'/../../temp'));
156-
157-
$config->expects($this->once())
158-
->method('getHydratorNamespace')
159-
->will($this->returnValue('Hydrator'));
160-
161-
$config->expects($this->any())
162-
->method('getDefaultDB')
163-
->will($this->returnValue('gedmo_extensions_test'));
164-
165-
$config->expects($this->once())
166-
->method('getAutoGenerateProxyClasses')
167-
->will($this->returnValue(true));
168-
169-
$config->expects($this->once())
170-
->method('getAutoGenerateHydratorClasses')
171-
->will($this->returnValue(true));
172-
173-
$config->expects($this->once())
174-
->method('getClassMetadataFactoryName')
175-
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataFactory'));
176-
177-
$config
178-
->expects($this->any())
179-
->method('getMongoCmd')
180-
->will($this->returnValue('$'))
181-
;
182-
183-
$config
184-
->expects($this->any())
185-
->method('getDefaultCommitOptions')
186-
->will($this->returnValue(array('safe' => true)))
187-
;
188-
189-
$mappingDriver = $this->getMetadataDriverImplementation();
190-
191-
$config->expects($this->any())
192-
->method('getMetadataDriverImpl')
193-
->will($this->returnValue($mappingDriver));
194-
195-
$config->expects($this->any())
196-
->method('getRepositoryFactory')
197-
->will($this->returnValue(new DefaultRepositoryFactory()));
198-
199-
$config->expects($this->any())
200-
->method('getDefaultRepositoryClassName')
201-
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\DocumentRepository'));
202-
203-
135+
$config = new \Doctrine\ODM\MongoDB\Configuration();
136+
$config->addFilter("softdeleteable", 'Gedmo\\SoftDeleteable\\Filter\\ODM\\SoftDeleteableFilter');
137+
$config->setProxyDir(__DIR__."/../../temp");
138+
$config->setHydratorDir(__DIR__."/../../temp");
139+
$config->setProxyNamespace("Proxy");
140+
$config->setHydratorNamespace("Hydrator");
141+
$config->setDefaultDB("gedmo_extensions_test");
142+
$config->setAutoGenerateProxyClasses(true);
143+
$config->setAutoGenerateHydratorClasses(true);
144+
$config->setMetadataDriverImpl($this->getMetadataDriverImplementation());
204145
return $config;
205146
}
206147
}

tests/Gedmo/Tool/BaseTestCaseOM.php

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -226,67 +226,19 @@ private function getEventManager()
226226
*/
227227
private function getMockAnnotatedODMMongoDBConfig($dbName, MappingDriver $mappingDriver = null)
228228
{
229-
$config = $this->getMock('Doctrine\\ODM\\MongoDB\\Configuration');
230-
$config->expects($this->once())
231-
->method('getProxyDir')
232-
->will($this->returnValue(__DIR__.'/../../temp'));
233-
234-
$config->expects($this->once())
235-
->method('getProxyNamespace')
236-
->will($this->returnValue('Proxy'));
237-
238-
$config->expects($this->once())
239-
->method('getHydratorDir')
240-
->will($this->returnValue(__DIR__.'/../../temp'));
241-
242-
$config->expects($this->once())
243-
->method('getHydratorNamespace')
244-
->will($this->returnValue('Hydrator'));
245-
246-
$config->expects($this->any())
247-
->method('getDefaultDB')
248-
->will($this->returnValue($dbName));
249-
250-
$config->expects($this->once())
251-
->method('getAutoGenerateProxyClasses')
252-
->will($this->returnValue(true));
253-
254-
$config->expects($this->once())
255-
->method('getAutoGenerateHydratorClasses')
256-
->will($this->returnValue(true));
257-
258-
$config->expects($this->once())
259-
->method('getClassMetadataFactoryName')
260-
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataFactory'));
261-
262-
$config
263-
->expects($this->any())
264-
->method('getMongoCmd')
265-
->will($this->returnValue('$'))
266-
;
267-
268-
$config
269-
->expects($this->any())
270-
->method('getDefaultCommitOptions')
271-
->will($this->returnValue(array('safe' => true)))
272-
;
273-
274229
if (null === $mappingDriver) {
275230
$mappingDriver = $this->getDefaultMongoODMMetadataDriverImplementation();
276231
}
277-
278-
$config->expects($this->any())
279-
->method('getMetadataDriverImpl')
280-
->will($this->returnValue($mappingDriver));
281-
282-
$config->expects($this->any())
283-
->method('getRepositoryFactory')
284-
->will($this->returnValue(new DefaultRepositoryFactoryODM()));
285-
286-
$config->expects($this->any())
287-
->method('getDefaultRepositoryClassName')
288-
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\DocumentRepository'));
289-
232+
$config = new \Doctrine\ODM\MongoDB\Configuration();
233+
$config->addFilter("softdeleteable", 'Gedmo\\SoftDeleteable\\Filter\\ODM\\SoftDeleteableFilter');
234+
$config->setProxyDir(__DIR__."/../../temp");
235+
$config->setHydratorDir(__DIR__."/../../temp");
236+
$config->setProxyNamespace("Proxy");
237+
$config->setHydratorNamespace("Hydrator");
238+
$config->setDefaultDB("gedmo_extensions_test");
239+
$config->setAutoGenerateProxyClasses(true);
240+
$config->setAutoGenerateHydratorClasses(true);
241+
$config->setMetadataDriverImpl($mappingDriver);
290242
return $config;
291243
}
292244

tests/Gedmo/Tree/MultiInheritanceWithSingleTableTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ protected function setUp()
3636
public function testConsistence()
3737
{
3838
$this->populate();
39+
$this->em->clear();
40+
3941
$carRepo = $this->em->getRepository(self::CAR);
4042
$audi = $carRepo->findOneByTitle('Audi-80');
4143
$this->assertEquals(2, $carRepo->childCount($audi));

0 commit comments

Comments
 (0)