Skip to content

Commit

Permalink
symfony#37180 Added test for stripping collection from dsn
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bennett committed Jun 15, 2020
1 parent 89f879e commit e8c54dd
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Symfony/Component/Lock/Tests/Store/MongoDbStoreTest.php
Expand Up @@ -147,10 +147,16 @@ public function testCollectionDsnPrecedence()
$client = self::getMongoClient();

$store = new MongoDbStore('mongodb://localhost/test?collection=lock_dsn', ['collection' => 'lock_option']);
$r = new \ReflectionObject($store);
$p = $r->getProperty('options');
$p->setAccessible(true);
$options = $p->getValue($store);
$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']);
}

Expand All @@ -159,10 +165,10 @@ public function testDatabaseDsnPrecedence()
$client = self::getMongoClient();

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

0 comments on commit e8c54dd

Please sign in to comment.