Skip to content

Commit 15e4e9c

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 1060a06 + 9ce0cb8 commit 15e4e9c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pkg/enqueue/Symfony/DefaultTransportFactory.php

+1-1
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

+18
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)