Skip to content

Commit

Permalink
attempt to fix mongodb odm dependency for php7
Browse files Browse the repository at this point in the history
  • Loading branch information
l3pp4rd committed Jul 3, 2016
1 parent c65fb62 commit 6edae82
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 136 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ php:
- 5.6
- 7.0

matrix:
allow_failures:
- php: 7.0

services: mongodb

before_install:
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo 'extension=mongo.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
- if [[ "$TRAVIS_PHP_VERSION" != 5.* ]]; then composer remove doctrine/mongodb-odm --no-update --dev; fi
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then composer remove alcaeus/mongo-php-adapter --no-update --dev; fi
- if [[ "$TRAVIS_PHP_VERSION" != 5.* ]]; then echo 'extension=mongodb.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi

install:
- composer install --prefer-dist
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@
"behat/transliterator": "~1.0",
"doctrine/common": "~2.4"
},
"replace": {
"ext-mongo": "1.6.12"
},
"require-dev": {
"doctrine/mongodb-odm": ">=1.0.2",
"alcaeus/mongo-php-adapter": "~1.0.4",
"doctrine/mongodb-odm": "~1.0",
"doctrine/orm": ">=2.5.0",
"doctrine/common": ">=2.5.0",
"symfony/yaml": "~2.6|~3.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Blameable/Fixture/Document/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Log
/**
* @var int $updated
*
* @ODM\Int
* @ODM\Field(type="int")
* @Gedmo\Blameable
*/
private $updated;
Expand Down
77 changes: 9 additions & 68 deletions tests/Gedmo/Tool/BaseTestCaseMongoODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\Common\EventManager;
use Doctrine\MongoDB\Connection;
use Doctrine\ODM\MongoDB\Repository\DefaultRepositoryFactory;
Expand Down Expand Up @@ -132,74 +133,14 @@ private function getEventManager()
*/
protected function getMockAnnotatedConfig()
{
$config = $this->getMock('Doctrine\\ODM\\MongoDB\\Configuration');

$config->expects($this->any())
->method('getFilterClassName')
->will($this->returnValue('Gedmo\\SoftDeleteable\\Filter\\ODM\\SoftDeleteableFilter'));

$config->expects($this->any())
->method('getFilterParameters')
->will($this->returnValue(array()));

$config->expects($this->once())
->method('getProxyDir')
->will($this->returnValue(__DIR__.'/../../temp'));

$config->expects($this->once())
->method('getProxyNamespace')
->will($this->returnValue('Proxy'));

$config->expects($this->once())
->method('getHydratorDir')
->will($this->returnValue(__DIR__.'/../../temp'));

$config->expects($this->once())
->method('getHydratorNamespace')
->will($this->returnValue('Hydrator'));

$config->expects($this->any())
->method('getDefaultDB')
->will($this->returnValue('gedmo_extensions_test'));

$config->expects($this->once())
->method('getAutoGenerateProxyClasses')
->will($this->returnValue(true));

$config->expects($this->once())
->method('getAutoGenerateHydratorClasses')
->will($this->returnValue(true));

$config->expects($this->once())
->method('getClassMetadataFactoryName')
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataFactory'));

$config
->expects($this->any())
->method('getMongoCmd')
->will($this->returnValue('$'))
;

$config
->expects($this->any())
->method('getDefaultCommitOptions')
->will($this->returnValue(array('safe' => true)))
;

$mappingDriver = $this->getMetadataDriverImplementation();

$config->expects($this->any())
->method('getMetadataDriverImpl')
->will($this->returnValue($mappingDriver));

$config->expects($this->any())
->method('getRepositoryFactory')
->will($this->returnValue(new DefaultRepositoryFactory()));

$config->expects($this->any())
->method('getDefaultRepositoryClassName')
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\DocumentRepository'));

$config = new Configuration();
$config->setProxyDir(__DIR__.'/../../temp');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(__DIR__.'/../../temp');
$config->setHydratorNamespace('Hydrators');
$config->setMetadataDriverImpl($this->getMetadataDriverImplementation());
$config->setDefaultDB("gedmo_extensions_test");
$config->addFilter("soft-deleteable", 'Gedmo\\SoftDeleteable\\Filter\\ODM\\SoftDeleteableFilter');

return $config;
}
Expand Down
69 changes: 8 additions & 61 deletions tests/Gedmo/Tool/BaseTestCaseOM.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,67 +225,14 @@ private function getEventManager()
*/
private function getMockAnnotatedODMMongoDBConfig($dbName, MappingDriver $mappingDriver = null)
{
$config = $this->getMock('Doctrine\\ODM\\MongoDB\\Configuration');
$config->expects($this->once())
->method('getProxyDir')
->will($this->returnValue(__DIR__.'/../../temp'));

$config->expects($this->once())
->method('getProxyNamespace')
->will($this->returnValue('Proxy'));

$config->expects($this->once())
->method('getHydratorDir')
->will($this->returnValue(__DIR__.'/../../temp'));

$config->expects($this->once())
->method('getHydratorNamespace')
->will($this->returnValue('Hydrator'));

$config->expects($this->any())
->method('getDefaultDB')
->will($this->returnValue($dbName));

$config->expects($this->once())
->method('getAutoGenerateProxyClasses')
->will($this->returnValue(true));

$config->expects($this->once())
->method('getAutoGenerateHydratorClasses')
->will($this->returnValue(true));

$config->expects($this->once())
->method('getClassMetadataFactoryName')
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataFactory'));

$config
->expects($this->any())
->method('getMongoCmd')
->will($this->returnValue('$'))
;

$config
->expects($this->any())
->method('getDefaultCommitOptions')
->will($this->returnValue(array('safe' => true)))
;

if (null === $mappingDriver) {
$mappingDriver = $this->getDefaultMongoODMMetadataDriverImplementation();
}

$config->expects($this->any())
->method('getMetadataDriverImpl')
->will($this->returnValue($mappingDriver));

$config->expects($this->any())
->method('getRepositoryFactory')
->will($this->returnValue(new DefaultRepositoryFactoryODM()));

$config->expects($this->any())
->method('getDefaultRepositoryClassName')
->will($this->returnValue('Doctrine\\ODM\\MongoDB\\DocumentRepository'));

$config = new \Doctrine\ODM\MongoDB\Configuration();
$config->setProxyDir(__DIR__.'/../../temp');
$config->setProxyNamespace('Proxies');
$config->setHydratorDir(__DIR__.'/../../temp');
$config->setHydratorNamespace('Hydrators');
$config->setMetadataDriverImpl($this->getDefaultMongoODMMetadataDriverImplementation());
$config->setDefaultDB("gedmo_extensions_test");
$config->addFilter("soft-deleteable", 'Gedmo\\SoftDeleteable\\Filter\\ODM\\SoftDeleteableFilter');
return $config;
}

Expand Down

0 comments on commit 6edae82

Please sign in to comment.