Skip to content

Commit

Permalink
symfony#37180 improved uri test
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bennett committed Jun 16, 2020
1 parent 599c128 commit 45e349d
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php
Expand Up @@ -142,33 +142,26 @@ public function provideInvalidConstructorArgs()
yield ['mongodb://localhost/', []];
}

public function testCollectionDsnPrecedence()
public function testUriPrecedence()
{
$client = self::getMongoClient();

$store = new MongoDbStore('mongodb://localhost/test?collection=lock_dsn', ['collection' => 'lock_option']);
$store = new MongoDbStore('mongodb://localhost/test_uri?collection=lock_uri', [
'database' => 'test_option',
'collection' => 'lock_option',
]);
$storeReflection = new \ReflectionObject($store);

$uriProperty = $storeReflection->getProperty('uri');
$uriProperty->setAccessible(true);
$uri = $uriProperty->getValue($store);
$this->assertSame('mongodb://localhost/test', $uri);

$optionsProperty = $storeReflection->getProperty('options');
$optionsProperty->setAccessible(true);
$options = $optionsProperty->getValue($store);
$this->assertSame('lock_dsn', $options['collection']);
}

public function testDatabaseDsnPrecedence()
{
$client = self::getMongoClient();
$this->assertSame('test_uri', $options['database']);
$this->assertSame('lock_uri', $options['collection']);

$store = new MongoDbStore('mongodb://localhost/test_dsn?collection=lock', ['database' => 'test_option']);
$storeReflection = new \ReflectionObject($store);
$optionsProperty = $storeReflection->getProperty('options');
$optionsProperty->setAccessible(true);
$options = $optionsProperty->getValue($store);
$this->assertSame('test_dsn', $options['database']);
$uriProperty = $storeReflection->getProperty('uri');
$uriProperty->setAccessible(true);
$uri = $uriProperty->getValue($store);
$this->assertSame('mongodb://localhost/test_uri', $uri);
}
}

0 comments on commit 45e349d

Please sign in to comment.