-
Notifications
You must be signed in to change notification settings - Fork 466
AMQPSocketConnection has a different parameters order, lets consider it #527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
use OldSound\RabbitMqBundle\Provider\ConnectionParametersProviderInterface; | ||
use OldSound\RabbitMqBundle\RabbitMq\AMQPConnectionFactory; | ||
use OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPConnection; | ||
use OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPSocketConnection; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AMQPConnectionFactoryTest extends TestCase | ||
|
@@ -37,6 +38,63 @@ public function testDefaultValues() | |
), $instance->constructParams); | ||
} | ||
|
||
public function testSocketConnection() | ||
{ | ||
$factory = new AMQPConnectionFactory( | ||
'OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPSocketConnection', | ||
array() | ||
); | ||
|
||
/** @var AMQPSocketConnection $instance */ | ||
$instance = $factory->createConnection(); | ||
$this->assertInstanceOf('PhpAmqpLib\Connection\AMQPSocketConnection', $instance); | ||
$this->assertEquals(array( | ||
'localhost', // host | ||
5672, // port | ||
'guest', // user | ||
'guest', // password | ||
'/', // vhost | ||
false, // insist | ||
"AMQPLAIN", // login method | ||
null, // login response | ||
"en_US", // locale | ||
3, // read_timeout | ||
false, // keepalive | ||
3, // write_timeout | ||
0, // heartbeat | ||
), $instance->constructParams); | ||
} | ||
|
||
public function testSocketConnectionWithParams() | ||
{ | ||
$factory = new AMQPConnectionFactory( | ||
'OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPSocketConnection', | ||
array( | ||
'read_timeout' => 31, | ||
'write_timeout' => 32, | ||
) | ||
); | ||
|
||
/** @var AMQPSocketConnection $instance */ | ||
$instance = $factory->createConnection(); | ||
$this->assertInstanceOf('PhpAmqpLib\Connection\AMQPSocketConnection', $instance); | ||
$this->assertEquals(array( | ||
'localhost', // host | ||
5672, // port | ||
'guest', // user | ||
'guest', // password | ||
'/', // vhost | ||
false, // insist | ||
"AMQPLAIN", // login method | ||
null, // login response | ||
"en_US", // locale | ||
31, // read_timeout | ||
false, // keepalive | ||
32, // write_timeout | ||
0, // heartbeat | ||
), $instance->constructParams); | ||
} | ||
|
||
public function testStandardConnectionParameters() | ||
{ | ||
$factory = new AMQPConnectionFactory( | ||
|
@@ -211,6 +269,28 @@ public function testSSLConnectionParameters() | |
), $instance->constructParams); | ||
} | ||
|
||
public function testConnectionsParametersProviderWithConstructorArgs() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this tests covers already |
||
{ | ||
$connectionParametersProvider = $this->prepareConnectionParametersProvider(); | ||
$connectionParametersProvider->expects($this->once()) | ||
->method('getConnectionParameters') | ||
->will($this->returnValue( | ||
array( | ||
'constructor_args' => array(1,2,3,4) | ||
) | ||
)); | ||
$factory = new AMQPConnectionFactory( | ||
'OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPConnection', | ||
array(), | ||
$connectionParametersProvider | ||
); | ||
|
||
/** @var AMQPConnection $instance */ | ||
$instance = $factory->createConnection(); | ||
$this->assertInstanceOf('OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPConnection', $instance); | ||
$this->assertEquals(array(1,2,3,4), $instance->constructParams); | ||
} | ||
|
||
public function testConnectionsParametersProvider() | ||
{ | ||
$connectionParametersProvider = $this->prepareConnectionParametersProvider(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures; | ||
|
||
use PhpAmqpLib\Connection\AMQPSocketConnection as BaseAMQPSocketConnection; | ||
|
||
class AMQPSocketConnection extends BaseAMQPSocketConnection | ||
{ | ||
public $constructParams; | ||
|
||
public function __construct() | ||
{ | ||
// save params for direct access in tests | ||
$this->constructParams = func_get_args(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not know really how to test this since will try to connect to rabbtmq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I forgot it extends from AbstractConnection