Skip to content

Commit

Permalink
Merge pull request #1893 from alcaeus/fix-missing-proxy-directory
Browse files Browse the repository at this point in the history
Fix missing proxy directory
  • Loading branch information
malarzm committed Nov 16, 2018
2 parents a6f482b + 03ef51a commit e74e5ed
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\ODM\MongoDB\PersistentCollection\DefaultPersistentCollectionGenerator;
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionFactory;
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionGenerator;
use Doctrine\ODM\MongoDB\Proxy\FileLocator;
use Doctrine\ODM\MongoDB\Repository\DefaultGridFSRepository;
use Doctrine\ODM\MongoDB\Repository\DefaultRepositoryFactory;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
Expand All @@ -22,7 +23,6 @@
use InvalidArgumentException;
use ProxyManager\Configuration as ProxyManagerConfiguration;
use ProxyManager\Factory\LazyLoadingGhostFactory;
use ProxyManager\FileLocator\FileLocator;
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
use ProxyManager\GeneratorStrategy\FileWriterGeneratorStrategy;
use ReflectionClass;
Expand Down
23 changes: 23 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Proxy/FileLocator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Proxy;

use ProxyManager\FileLocator\FileLocator as BaseFileLocator;
use function mkdir;
use function realpath;

final class FileLocator extends BaseFileLocator
{
public function __construct(string $proxiesDirectory)
{
$absolutePath = realpath($proxiesDirectory);

if ($absolutePath === false) {
mkdir($proxiesDirectory, 0755, true);
}

parent::__construct($proxiesDirectory);
}
}
5 changes: 5 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function tearDown()
$collections = $client->selectDatabase(DOCTRINE_MONGODB_DATABASE)->listCollections();

foreach ($collections as $collection) {
// See https://jira.mongodb.org/browse/SERVER-16541
if ($collection->getName() === 'system.indexes') {
continue;
}

$client->selectCollection(DOCTRINE_MONGODB_DATABASE, $collection->getName())->drop();
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Doctrine/ODM/MongoDB/Tests/Functional/IndexesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function testIndexDefinitions()

/**
* @expectedException \MongoDB\Driver\Exception\BulkWriteException
* @expectedExceptionMessage duplicate key error collection
* @expectedExceptionMessage duplicate key error
*/
public function testUniqueIndexOnField()
{
Expand All @@ -180,7 +180,7 @@ public function testUniqueIndexOnField()

/**
* @expectedException \MongoDB\Driver\Exception\BulkWriteException
* @expectedExceptionMessage duplicate key error collection
* @expectedExceptionMessage duplicate key error
*/
public function testUniqueIndexOnDocument()
{
Expand All @@ -189,7 +189,7 @@ public function testUniqueIndexOnDocument()

/**
* @expectedException \MongoDB\Driver\Exception\BulkWriteException
* @expectedExceptionMessage duplicate key error collection
* @expectedExceptionMessage duplicate key error
*/
public function testIndexesOnDocument()
{
Expand All @@ -198,7 +198,7 @@ public function testIndexesOnDocument()

/**
* @expectedException \MongoDB\Driver\Exception\BulkWriteException
* @expectedExceptionMessage duplicate key error collection
* @expectedExceptionMessage duplicate key error
*/
public function testMultipleFieldsUniqueIndexOnDocument()
{
Expand All @@ -207,7 +207,7 @@ public function testMultipleFieldsUniqueIndexOnDocument()

/**
* @expectedException \MongoDB\Driver\Exception\BulkWriteException
* @expectedExceptionMessage duplicate key error collection
* @expectedExceptionMessage duplicate key error
*/
public function testMultipleFieldIndexes()
{
Expand Down

0 comments on commit e74e5ed

Please sign in to comment.