Skip to content

Commit 4bcb13a

Browse files
committed
Fixes a warning that gets emitted when mocking AMQPChannel with some methods
1 parent d829473 commit 4bcb13a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

PhpAmqpLib/Channel/AMQPChannel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function channel_alert($args)
152152
*/
153153
public function close($reply_code = 0, $reply_text = "", $method_sig = array(0, 0))
154154
{
155-
if ($this->is_open !== true || !$this->connection || !$this->connection->isConnected()) {
155+
if ((isset($this->is_open) && $this->is_open !== true) || !$this->connection || !$this->connection->isConnected()) {
156156
$this->do_close();
157157
return; // already closed
158158
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace PhpAmqpLib\Tests\Unit\Channel;
4+
5+
use PhpAmqpLib\Channel\AMQPChannel;
6+
7+
class AMQPChannelTest extends \PHPUnit_Framework_TestCase
8+
{
9+
public function testCloseDoesNotEmitUndefinedPropertyWarningWhenSomeMethodsAreMocked()
10+
{
11+
$mockChannel = $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel')
12+
->setMethods(array('queue_bind'))
13+
->disableOriginalConstructor()
14+
->getMock();
15+
/* @var $mockChannel \PhpAmqpLib\Channel\AMQPChannel */
16+
17+
$mockChannel->close();
18+
}
19+
}

0 commit comments

Comments
 (0)