bug #27001 [Messenger] Typecast the auto-setup as a bool. (davidbarratt)

This PR was squashed before being merged into the 4.1-dev branch (closes #27001).

Discussion
----------

[Messenger] Typecast the auto-setup as a bool.

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #26996
| License       | MIT
| Doc PR        |

Commits
-------

566a8be35b [Messenger] Typecast the auto-setup as a bool.
This commit is contained in:
Fabien Potencier 2018-04-25 12:51:12 +02:00
commit f7264ed971
2 changed files with 7 additions and 1 deletions

View File

@ -218,6 +218,6 @@ class Connection
private function shouldSetup(): bool
{
return !array_key_exists('auto-setup', $this->connectionCredentials) || 'false' !== $this->connectionCredentials['auto-setup'];
return !array_key_exists('auto-setup', $this->connectionCredentials) || !in_array($this->connectionCredentials['auto-setup'], array(false, 'false'), true);
}
}

View File

@ -182,6 +182,12 @@ class ConnectionTest extends TestCase
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key', array('auto-setup' => 'false'), true, $factory);
$connection->publish('body');
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key', array('auto-setup' => false), true, $factory);
$connection->publish('body');
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key&auto-setup=false', array(), true, $factory);
$connection->publish('body');
}
}