Skip to content

Commit d2fb924

Browse files
committed
Rework phpunit.xml; remove references to mongo
1 parent 475c217 commit d2fb924

File tree

4 files changed

+29
-37
lines changed

4 files changed

+29
-37
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
vendor/
22
composer.phar
3-
composer.lock
3+
composer.lock
4+
.phpunit.cache/
5+
.phpunit.result.cache
6+
coverage/

phpunit.xml

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="./test/src/Bootstrap.php" colors="true">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
4+
bootstrap="test/src/Bootstrap.php"
5+
colors="true"
6+
cacheResultFile=".phpunit.cache/test-results"
7+
executionOrder="depends,defects"
8+
forceCoversAnnotation="false"
9+
beStrictAboutCoversAnnotation="true"
10+
beStrictAboutOutputDuringTests="true"
11+
beStrictAboutTodoAnnotatedTests="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
315
<testsuites>
4-
<testsuite name="Main">
16+
<testsuite name="default">
517
<file>./test/src/Tests/ModuleTest.php</file>
6-
<directory>./test/src/Tests/Service</directory>
18+
<directory suffix="Test.php">test/src/Tests/Service</directory>
719
<file>./test/src/Tests/Hydrator/DoctrineHydratorTest.php</file>
820
</testsuite>
921
</testsuites>
22+
23+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
24+
processUncoveredFiles="true">
25+
<include>
26+
<directory suffix=".php">src</directory>
27+
</include>
28+
</coverage>
1029
</phpunit>

src/Service/DoctrineHydratorFactory.php

+3-19
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
namespace ApiSkeletons\DoctrineORMHydrationModule\Service;
44

55
use Doctrine\Common\Persistence\ObjectManager;
6-
use Doctrine\ODM\MongoDB\DocumentManager;
76
use Doctrine\ORM\EntityManager;
87
use DoctrineModule\Persistence\ObjectManagerAwareInterface;
98
use DoctrineModule\Stdlib\Hydrator;
109
use Doctrine\Laminas\Hydrator\DoctrineObject;
1110
use Interop\Container\ContainerInterface;
1211
use ApiSkeletons\DoctrineORMHydrationModule\Hydrator\DoctrineHydrator;
13-
use ApiSkeletons\DoctrineORMHydrationModule\Hydrator\ODM\MongoDB;
1412
use Laminas\Hydrator\AbstractHydrator;
1513
use Laminas\Hydrator\Filter\FilterComposite;
1614
use Laminas\Hydrator\Filter\FilterInterface;
@@ -32,7 +30,6 @@ class DoctrineHydratorFactory implements AbstractFactoryInterface
3230
{
3331
const FACTORY_NAMESPACE = 'doctrine-hydrator';
3432

35-
const OBJECT_MANAGER_TYPE_ODM_MONGODB = 'ODM/MongoDB';
3633
const OBJECT_MANAGER_TYPE_ORM = 'ORM';
3734

3835
/**
@@ -190,9 +187,7 @@ public function createServiceWithName(ServiceLocatorInterface $hydratorManager,
190187
*/
191188
protected function getObjectManagerType($objectManager)
192189
{
193-
if (class_exists(DocumentManager::class) && $objectManager instanceof DocumentManager) {
194-
return self::OBJECT_MANAGER_TYPE_ODM_MONGODB;
195-
} elseif (class_exists(EntityManager::class) && $objectManager instanceof EntityManager) {
190+
if (class_exists(EntityManager::class) && $objectManager instanceof EntityManager) {
196191
return self::OBJECT_MANAGER_TYPE_ORM;
197192
}
198193

@@ -226,14 +221,7 @@ protected function loadObjectManager(ContainerInterface $container, $config)
226221
protected function loadEntityHydrator(ContainerInterface $container, $config, $objectManager)
227222
{
228223
$objectManagerType = $this->getObjectManagerType($objectManager);
229-
if ($objectManagerType != self::OBJECT_MANAGER_TYPE_ODM_MONGODB) {
230-
return;
231-
}
232-
233-
$hydratorFactory = $objectManager->getHydratorFactory();
234-
$hydrator = $hydratorFactory->getHydratorFor($config['entity_class']);
235-
236-
return $hydrator;
224+
return;
237225
}
238226

239227
/**
@@ -247,11 +235,7 @@ protected function loadDoctrineModuleHydrator(ContainerInterface $container, $co
247235
{
248236
$objectManagerType = $this->getObjectManagerType($objectManager);
249237

250-
if ($objectManagerType == self::OBJECT_MANAGER_TYPE_ODM_MONGODB) {
251-
$hydrator = new MongoDB\DoctrineObject($objectManager, $config['by_value']);
252-
} else {
253-
$hydrator = new DoctrineObject($objectManager, $config['by_value']);
254-
}
238+
$hydrator = new DoctrineObject($objectManager, $config['by_value']);
255239

256240
return $hydrator;
257241
}

test/src/Bootstrap.php

-14
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function __construct($autoLoader)
3535
public function init()
3636
{
3737
$this->initAutoLoading();
38-
$this->configureDoctrineODM();
3938
}
4039

4140
/**
@@ -50,19 +49,6 @@ protected function initAutoLoading()
5049
'Doctrine\\ODM\\MongoDB\\Tests\\BaseTest' => PROJECT_BASE_PATH.'/vendor/doctrine/mongodb-odm/tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php',
5150
));
5251
}
53-
54-
/**
55-
* Load all doctrine ODM configuration:.
56-
*/
57-
protected function configureDoctrineODM()
58-
{
59-
// Constants
60-
define('DOCTRINE_MONGODB_DATABASE', 'hydrator-tests');
61-
define('DOCTRINE_MONGODB_SERVER', 'mongodb://mongo:27017');
62-
63-
// Load annotated classes
64-
// \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::registerAnnotationClasses();
65-
}
6652
}
6753

6854
$autoLoader = require $autoloadFile;

0 commit comments

Comments
 (0)