Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #43 from webimpress/feature/doctrine-module-2.1
Browse files Browse the repository at this point in the history
Added support for DoctrineModule 2.1
  • Loading branch information
veewee authored Jan 18, 2019
2 parents 3b9b7cd + 182bcc0 commit 8cb3c1d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 27 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sudo: false
language: php

cache:
Expand All @@ -17,6 +16,12 @@ matrix:
env: DEPENDENCIES='low' MONGO_VERSION=stable
- php: 7.0
env: ADAPTER_VERSION="^1.0.0" MONGODB_VERSION=stable
- php: 7.1
env: ADAPTER_VERSION="^1.0.0" MONGODB_VERSION=stable
- php: 7.2
env: ADAPTER_VERSION="^1.0.0" MONGODB_VERSION=stable
- php: 7.3
env: ADAPTER_VERSION="^1.0.0" MONGODB_VERSION=stable

before_install:
- phpenv config-add .travis-config.ini || return 0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Make sure to commit on the correct branch if you want your changes to get merged

## Add to composer.json
```
composer require phpro/zf-doctrine-hydration-module:^3.0
composer require phpro/zf-doctrine-hydration-module
```

## Add to application config
Expand Down
15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"description": "Doctrine hydrators for ZF2 and ZF3",
"keywords": [
"zf2",
"zf",
"doctrine",
"hydrator"
],
Expand All @@ -21,18 +21,17 @@
"require": {
"php": "^5.6 || ^7.0",
"doctrine/common": "^2.6.1",
"doctrine/doctrine-module": "^1.2 || ^2.1.7",
"doctrine/instantiator": "^1.0.5",
"zendframework/zend-servicemanager": "^3.3.2",
"zendframework/zend-hydrator": "^1.1 || ^2.2.1",
"zendframework/zend-modulemanager": "^2.7.2",
"api-skeletons/zf-doctrine-module-zend-hydrator": "^1.0",
"doctrine/doctrine-module": "^1.2",
"doctrine/instantiator": "^1.0.5"
"zendframework/zend-modulemanager": "^2.7.2"
},
"require-dev": {
"fabpot/PHP-CS-Fixer": "^1.11.6",
"phpunit/phpunit": "^4.8",
"doctrine/doctrine-orm-module": "^1.1",
"doctrine/doctrine-mongo-odm-module": "^0.11",
"phpunit/phpunit": "^5.7.27",
"doctrine/doctrine-orm-module": "^1.1 || ^2.1.2",
"doctrine/doctrine-mongo-odm-module": "^0.11 || ^1.0",
"doctrine/mongodb-odm": "^1.1",
"phpro/grumphp": "^0.9.1"
},
Expand Down
13 changes: 7 additions & 6 deletions test/src/Tests/Hydrator/DoctrineHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace PhproTest\DoctrineHydrationModule\Tests\Hydrator;

use Phpro\DoctrineHydrationModule\Hydrator\DoctrineHydrator;
use PHPUnit\Framework\TestCase;

/**
* Class DoctrineHydratorTest.
*/
class DoctrineHydratorTest extends \PHPUnit_Framework_TestCase
class DoctrineHydratorTest extends TestCase
{
/**
* @param null $hydrateService
Expand All @@ -17,8 +18,8 @@ class DoctrineHydratorTest extends \PHPUnit_Framework_TestCase
*/
protected function createHydrator($hydrateService = null, $extractService = null)
{
$hydrateService = $hydrateService ? $hydrateService : $this->getMock('Zend\Hydrator\HydratorInterface');
$extractService = $extractService ? $extractService : $this->getMock('Zend\Hydrator\HydratorInterface');
$hydrateService = $hydrateService ? $hydrateService : $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();
$extractService = $extractService ? $extractService : $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();

return new DoctrineHydrator($extractService, $hydrateService);
}
Expand Down Expand Up @@ -57,7 +58,7 @@ public function it_should_extract_an_object()
{
$object = new \stdClass();
$extracted = array('extracted' => true);
$extractService = $this->getMock('Zend\Hydrator\HydratorInterface');
$extractService = $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();
$extractService
->expects($this->any())
->method('extract')
Expand All @@ -77,7 +78,7 @@ public function it_should_hydrate_an_object()
$object = new \stdClass();
$data = array('field' => 'value');

$hydrateService = $this->getMock('Zend\Hydrator\HydratorInterface');
$hydrateService = $this->getMockBuilder('Zend\Hydrator\HydratorInterface')->getMock();
$hydrateService
->expects($this->any())
->method('hydrate')
Expand All @@ -98,7 +99,7 @@ public function it_should_use_a_generated_doctrine_hydrator_while_hydrating_an_o
$object = new \stdClass();
$data = array('field' => 'value');

$hydrateService = $this->getMock('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface');
$hydrateService = $this->getMockBuilder('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface')->getMock();
$hydrateService
->expects($this->any())
->method('hydrate')
Expand Down
4 changes: 3 additions & 1 deletion test/src/Tests/Hydrator/ODM/MongoDB/DoctrineObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class DoctrineObjectTest extends BaseTest
*/
protected function createHydrator($objectManager = null)
{
$objectManager = $objectManager ? $objectManager : $this->getMock('Doctrine\ODM\MongoDB\DocumentManager', array(), array(), '', false);
$objectManager = $objectManager ? $objectManager : $this->getMockBuilder('Doctrine\ODM\MongoDB\DocumentManager')
->disableOriginalConstructor()
->getMock();
$hydrator = new DoctrineObject($objectManager);

return $hydrator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace PhproTest\DoctrineHydrationModule\Tests\Hydrator\ODM\MongoDB\Strategy;

use Phpro\DoctrineHydrationModule\Hydrator\ODM\MongoDB\Strategy\DateTimeField;
use PHPUnit\Framework\TestCase;

/**
* Class DateTimeFieldTest.
*/
class DateTimeFieldTest extends \PHPUnit_Framework_TestCase
class DateTimeFieldTest extends TestCase
{
/**
* @param bool $isTimestamp
Expand Down
3 changes: 2 additions & 1 deletion test/src/Tests/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace PhproTest\DoctrineHydrationModule\Tests;

use Phpro\DoctrineHydrationModule\Module;
use PHPUnit\Framework\TestCase;

/**
* Class ModuleTest.
*/
class ModuleTest extends \PHPUnit_Framework_TestCase
class ModuleTest extends TestCase
{
/**
* @test
Expand Down
33 changes: 25 additions & 8 deletions test/src/Tests/Service/DoctrineHydratorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

use PhproTest\DoctrineHydrationModule\Hydrator\CustomBuildHydratorFactory;
use Phpro\DoctrineHydrationModule\Service\DoctrineHydratorFactory;
use PHPUnit\Framework\TestCase;
use Zend\ServiceManager\ServiceManager;
use Zend\Hydrator\HydratorPluginManager;

class DoctrineHydratorFactoryTest extends \PHPUnit_Framework_TestCase
class DoctrineHydratorFactoryTest extends TestCase
{
/**
* @var array
Expand All @@ -34,9 +35,18 @@ protected function setUp()
$this->serviceManager = new ServiceManager();
$this->serviceManager->setAllowOverride(true);
$this->serviceManager->setService('config', $this->serviceConfig);
$this->serviceManager->setService('custom.strategy', $this->getMock('Zend\Hydrator\Strategy\StrategyInterface'));
$this->serviceManager->setService('custom.filter', $this->getMock('Zend\Hydrator\Filter\FilterInterface'));
$this->serviceManager->setService('custom.naming_strategy', $this->getMock('Zend\Hydrator\NamingStrategy\NamingStrategyInterface'));
$this->serviceManager->setService(
'custom.strategy',
$this->getMockBuilder('Zend\Hydrator\Strategy\StrategyInterface')->getMock()
);
$this->serviceManager->setService(
'custom.filter',
$this->getMockBuilder('Zend\Hydrator\Filter\FilterInterface')->getMock()
);
$this->serviceManager->setService(
'custom.naming_strategy',
$this->getMockBuilder('Zend\Hydrator\NamingStrategy\NamingStrategyInterface')->getMock()
);

$this->hydratorManager = $this->getMockBuilder(HydratorPluginManager::class)
->disableOriginalConstructor()
Expand All @@ -55,7 +65,9 @@ protected function setUp()
*/
protected function stubObjectManager($objectManagerClass)
{
$objectManager = $this->getMock($objectManagerClass, array(), array(), '', false);
$objectManager = $this->getMockBuilder($objectManagerClass)
->disableOriginalConstructor()
->getMock();
$this->serviceManager->setService('doctrine.default.object-manager', $objectManager);

return $objectManager;
Expand Down Expand Up @@ -153,8 +165,10 @@ public function it_should_create_a_custom_ODM_hydrator_which_uses_the_auto_gener
$this->serviceManager->setService('config', $this->serviceConfig);
$objectManager = $this->stubObjectManager('Doctrine\ODM\MongoDb\DocumentManager');

$hydratorFactory = $this->getMock('Doctrine\ODM\MongoDB\Hydrator\HydratorFactory', array(), array(), '', false);
$generatedHydrator = $this->getMock('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface');
$hydratorFactory = $this->getMockBuilder('Doctrine\ODM\MongoDB\Hydrator\HydratorFactory')
->disableOriginalConstructor()
->getMock();
$generatedHydrator = $this->getMockBuilder('Doctrine\ODM\MongoDB\Hydrator\HydratorInterface')->getMock();

$objectManager
->expects($this->any())
Expand Down Expand Up @@ -183,7 +197,10 @@ public function it_should_be_possible_to_configure_a_custom_hydrator()
$this->serviceConfig['doctrine-hydrator']['custom-hydrator']['hydrator'] = 'custom.hydrator';
$this->serviceManager->setService('config', $this->serviceConfig);

$this->serviceManager->setService('custom.hydrator', $this->getMock('Zend\Hydrator\ArraySerializable'));
$this->serviceManager->setService(
'custom.hydrator',
$this->getMockBuilder('Zend\Hydrator\ArraySerializable')->getMock()
);

$hydrator = $this->createOrmHydrator();

Expand Down

0 comments on commit 8cb3c1d

Please sign in to comment.