Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations when running against ODM 1.3 #586

Merged
merged 1 commit into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
- DRIVER_VERSION="stable"
- ADAPTER_VERSION="^1.0.0"
- COMPOSER_FLAGS="--prefer-dist"
- SYMFONY_DEPRECATIONS_HELPER="max[self]=0"

matrix:
include:
Expand Down
2 changes: 1 addition & 1 deletion Repository/ContainerRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function getOrCreateRepository(DocumentManager $documentManager, ClassMe
return $this->managedRepositories[$repositoryHash];
}

$repositoryClassName = $metadata->customRepositoryClassName ?: $documentManager->getConfiguration()->getDefaultRepositoryClassName();
$repositoryClassName = $metadata->customRepositoryClassName ?: (method_exists($documentManager->getConfiguration(), 'getDefaultDocumentRepositoryClassName') ? $documentManager->getConfiguration()->getDefaultDocumentRepositoryClassName() : $documentManager->getConfiguration()->getDefaultRepositoryClassName());

return $this->managedRepositories[$repositoryHash] = new $repositoryClassName($documentManager, $documentManager->getUnitOfWork(), $metadata);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/Fixtures/config/yml/full.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
doctrine_mongodb:
fixture_loader: Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader
auto_generate_proxy_classes: true
auto_generate_proxy_classes: 2
auto_generate_hydrator_classes: true
auto_generate_persistent_collection_classes: 3
default_connection: conn1
Expand Down
3 changes: 3 additions & 0 deletions Tests/Mapping/Driver/YamlDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\YamlDriver;

/**
* @group legacy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems unrelated, is it some magic group name that allows deprecations to be present?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The group tells the Symfony deprecation handler to ignore all deprecation notices that come up during the execution of this test. This can be done to specifically test legacy behaviour without having to define an exception for the deprecation in configuration.

*/
class YamlDriverTest extends AbstractDriverTest
{
protected function getFileExtension()
Expand Down
3 changes: 2 additions & 1 deletion Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Doctrine\Bundle\MongoDBBundle\Tests;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Proxy\AbstractProxyFactory;
use Doctrine\MongoDB\Connection;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
Expand All @@ -17,7 +18,7 @@ class TestCase extends BaseTestCase
public static function createTestDocumentManager($paths = [])
{
$config = new \Doctrine\ODM\MongoDB\Configuration();
$config->setAutoGenerateProxyClasses(true);
$config->setAutoGenerateProxyClasses(AbstractProxyFactory::AUTOGENERATE_FILE_NOT_EXISTS);
$config->setProxyDir(\sys_get_temp_dir());
$config->setHydratorDir(\sys_get_temp_dir());
$config->setProxyNamespace('SymfonyTests\Doctrine');
Expand Down