Skip to content

Commit b44a6e8

Browse files
author
Jak Spalding
committed
fix: polling_interval is an integer
1 parent dfea18e commit b44a6e8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Diff for: pkg/mongodb/MongodbConnectionFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static function parseDsn(string $dsn): array
9898
parse_str($parsedUrl['query'], $queryParts);
9999
//get enqueue attributes values
100100
if (!empty($queryParts['polling_interval'])) {
101-
$config['polling_interval'] = $queryParts['polling_interval'];
101+
$config['polling_interval'] = (int) $queryParts['polling_interval'];
102102
}
103103
if (!empty($queryParts['enqueue_collection'])) {
104104
$config['collection_name'] = $queryParts['enqueue_collection'];

Diff for: pkg/mongodb/Tests/MongodbConnectionFactoryTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ public function testCouldBeConstructedWithCustomConfiguration()
4545
$this->assertAttributeEquals($params, 'config', $factory);
4646
}
4747

48+
public function testCouldBeConstructedWithCustomConfigurationFromDsn()
49+
{
50+
$params = [
51+
'dsn' => 'mongodb://127.0.0.3/test-db-name?enqueue_collection=collection-name&polling_interval=3000',
52+
'dbname' => 'test-db-name',
53+
'collection_name' => 'collection-name',
54+
'polling_interval' => 3000,
55+
];
56+
57+
$factory = new MongodbConnectionFactory($params['dsn']);
58+
59+
$this->assertAttributeEquals($params, 'config', $factory);
60+
}
61+
4862
public function testShouldCreateContext()
4963
{
5064
$factory = new MongodbConnectionFactory();

0 commit comments

Comments
 (0)