From 45e349dc14a66ca9ef895d2e5883611b40a51680 Mon Sep 17 00:00:00 2001 From: Joe Bennett Date: Tue, 16 Jun 2020 12:20:14 +1000 Subject: [PATCH] #37180 improved uri test --- .../Lock/Tests/Store/MongoDbStoreTest.php | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php index b48224bbc940d..5cad694af564c 100644 --- a/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php @@ -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); } }