Skip to content

Commit 49a2ec5

Browse files
authored
Merge pull request #358 from php-enqueue/bundle-fix-default-transport-and-dsn
[bundle] DefaultTransportFactory should accept DSN like foo:
2 parents a4122cd + 75104e0 commit 49a2ec5

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎pkg/enqueue/Symfony/DefaultTransportFactory.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function addConfiguration(ArrayNodeDefinition $builder)
5858
}
5959

6060
if (is_string($v)) {
61-
return false !== strpos($v, '://') || false !== strpos($v, 'env_') ?
61+
return false !== strpos($v, ':') || false !== strpos($v, 'env_') ?
6262
['dsn' => $v] :
6363
['alias' => $v];
6464
}

‎pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ public function testShouldAllowAddConfigurationAsDsn()
7272
$this->assertEquals(['dsn' => 'dsn://'], $config);
7373
}
7474

75+
/**
76+
* @see https://github.com/php-enqueue/enqueue-dev/issues/356
77+
*
78+
* @group bug
79+
*/
80+
public function testShouldAllowAddConfigurationAsDsnWithoutSlashes()
81+
{
82+
$transport = new DefaultTransportFactory();
83+
$tb = new TreeBuilder();
84+
$rootNode = $tb->root('foo');
85+
86+
$transport->addConfiguration($rootNode);
87+
$processor = new Processor();
88+
$config = $processor->process($tb->buildTree(), ['dsn:']);
89+
90+
$this->assertEquals(['dsn' => 'dsn:'], $config);
91+
}
92+
7593
public function testShouldSetNullTransportByDefault()
7694
{
7795
$transport = new DefaultTransportFactory();

0 commit comments

Comments
 (0)